Simple Solution without any extra data structure
Find the target node.\n2. Get the nodes down to the target node at required distance\n3. Return 1 as a distance of target node to the parent.\n4. At parent, if 
1. Find the target node.\n2. Get the nodes down to the target node at required distance\n3. Return 1 as a distance of target node to the parent.\n4. At parent, if returned distance is greater than zero means, we have found the target node.\n5. If parent is at required distance from target node, record parent in the ret list.\n6. Else, move to the other branch of the tree with distance as K - (returned from target) - 1. We have to do -1, because we already moved to the different branch from parent.\n```\npublic List<Integer> distanceK(TreeNode root, TreeNode target, int K) {\n        List<Integer> ret = new ArrayList<>();\n        distanceK(root,target,K,ret);\n        return ret;\n    }\n    private void getDownNodes(TreeNode node,int d, List<Integer> ret){\n        if(node==null)return;\n        if(d==0){\n            ret.add(node.val);\n        }\n        getDownNodes(node.left,d-1,ret);\n        getDownNodes(node.right,d-1,ret);\n    }\n    private int distanceK(TreeNode root, TreeNode target, int K, List<Integer> ret ) {\n        if(root==null){\n            return -1;\n        }\n        if(root==target){\n            getDownNodes(target,K,ret);\n            return 1;\n        }\n        int d1=distanceK(root.left,target,K,ret);\n        if(d1>=0){\n            if(d1==K){\n                ret.add(root.val);\n            } else{\n                getDownNodes(root.right,K-d1-1,ret);\n            }\n            return d1+1;\n        }\n        int d2=distanceK(root.right,target,K,ret);\n        if(d2>=0){\n            if(d2==K){\n                ret.add(root.val);\n            } else{\n                getDownNodes(root.left,K-d2-1,ret);\n            }\n            return d2+1;\n        }\n        return -1;\n        \n    }\n```
[]