Corrected logic in inorderTraverse method