Implemented a funciton to print the tree