When you expand an array/tree where each member has a pointer to other member, but realloc sometimes copy the old data and the pointers are gone.
What im doing now is instead of pointers im using indexes, but its not enough flexible if you want to go up/down to parent/child trees. Other solution might be to create another struct which will hold the indices, or simply not using realloc at all and make linked list of arrays. This is pain it the a.
Does Nim have any mechanism to overcome this?
This is a common problem in graph data structures.
Either you store a tree of references or you use an adjacency matrix.