Easy + Straightforward Python DFS beats 90%
\nclass Solution:\n    def distanceK(self, root: TreeNode, target: TreeNode, k: int) -> List[int]:\n        \n        def helper(node, parent):\n            if 
```\nclass Solution:\n    def distanceK(self, root: TreeNode, target: TreeNode, k: int) -> List[int]:\n        \n        def helper(node, parent):\n            if not node:\n                return\n            node.parent = parent\n            helper(node.left, node)\n            helper(node.right, node)\n            \n        helper(root, None)\n        ans = []\n        seen = set()\n        \n        def trav(node, dist):\n            if not node or node in seen or dist > k:\n                return\n            seen.add(node)\n            if dist == k:\n                ans.append(node.val)\n                return\n            if dist+1 <= k:\n                trav(node.parent, dist+1)\n                trav(node.left, dist+1)\n                trav(node.right, dist+1)\n        \n        trav(target, 0)\n        return ans\n\n```
['Depth-First Search', 'Python', 'Python3']