preorder traversal solution