Fixed preorder traversal bug