added a function to print the tree in preorder