I am trying create Tree component from scratch. Each node can have list of nodes. Any node can be expanded or not.
Is necessary one list across all list,
for example:
Code:
 a
   b
     d
     e
   c
    f
 g
this list will be a b d e c f g (visual position a=0,b=1,d=2 etc)
whereas physically elements are stored on lists:
root-> a, g
a->b,c
b->d,e
c->f

My two problems:
1. find visual position for node
2. find node for visual position
Point 2 will be easy if exists list of this nodes, for example a b d e c f g
If expand, collapse, we must move block, if b collapses then list will a b c f g
Point 1 still difficult
Worst - adding node requires point 1 and move block many times - it is too slow

Second solution: In list is field VisibleCount - semi-expanded size of each branch
add node requires update VisibleCount only parent, parent->parent etc..
But points 1 and 2 still difficult