unflatten tree
tree init function