add preorder traversal without recursion