Javascript DFS
\nvar distanceK = function(root, target, K) {\n  if(!root) return []\n  const node = findTarget(root, null, target)  \n  const res = []\n  findAllKApart(node, K
```\nvar distanceK = function(root, target, K) {\n  if(!root) return []\n  const node = findTarget(root, null, target)  \n  const res = []\n  findAllKApart(node, K, res)\n  return res\n};\n\nfunction findTarget(root, parent, target){\n  if(!root) return null\n  root.parent = parent\n  if(root === target){    \n   return root \n  }    \n  return findTarget(root.left, root, target) || findTarget(root.right, root, target)    \n}\n\nfunction findAllKApart(root, k, res){\n  if(!root || root.visited) return res\n  if(k == 0){\n    res.push(root.val)\n    return res\n  }   \n  root.visited = true\n  findAllKApart(root.left, k-1, res)\n  findAllKApart(root.right, k-1, res)\n  findAllKApart(root.parent, k-1, res)\n  return res\n}\n```
['Depth-First Search', 'JavaScript']