Have a generic tree structure
The tree structure should not use too heavily the preprocessor, should not add levels of indirection, and should be generic. The nodes should have a pointer to the upper node. The node pruning should be possible, knowing that all iterators would be invalidated.
Then, another layer should add the following function: iterator_first_child, iterator_next_sibling, iterator_previous_sibling, iterator_parent.