Implemented the main logic to build the tree
Implemented the main logic to build the tree