solution for inorder traversal problem