Optimizations for the tree generator.
Added parent to all nodes.