building the tree