refactored the BinaryTree