Java PreOrder Recursive Solution 10 Lines Explained.
Parent node needs to know whether its children are deleted, so we can update their pointers to null. On the other hand, children needs to know if their parents 
Parent node needs to know whether its children are deleted, so we can update their pointers to null. On the other hand, children needs to know if their parents are deleted, so they become new roots which we will have to add to our answer arraylist. \n\nIn other words, we need to pass down information from parents to children and from children to parent. \nFor information from parents to children, we can pass that down via the parameter inside the method signature, and for info from children to parents, we can pass that via the return type. \n```\nclass Solution {\n    public List<TreeNode> delNodes(TreeNode root, int[] to_delete) {\n        List<TreeNode> ans = new ArrayList<>();\n        Set<Integer> set = new HashSet<>();\n        for (int t : to_delete) set.add(t);\n        preorder(root, set , ans, true);\n        return ans;\n    }\n\n    private static boolean preorder(TreeNode root, Set<Integer> delete, List<TreeNode> ans, boolean isRoot){\n        if (root == null) return false;\n        if (isRoot && !delete.contains(root.val)) ans.add(root);\n        isRoot = delete.contains(root.val);\n        if (preorder(root.left , delete, ans, isRoot)) root.left = null;\n        if (preorder(root.right, delete, ans, isRoot)) root.right= null;\n        return isRoot;\n    }\n}\n```
['Recursion', 'Java']