Finished the tree parsing function.