used pointers for tree unflattening