Java : Post order traversal based clean & easy to understand
\nclass Solution {\n    public List<TreeNode> delNodes(TreeNode root, int[] to_delete) {\n        List<TreeNode> answer = new ArrayList<>();\n        \n        
```\nclass Solution {\n    public List<TreeNode> delNodes(TreeNode root, int[] to_delete) {\n        List<TreeNode> answer = new ArrayList<>();\n        \n        Set<Integer> toDelete = new HashSet<>();\n        for(int i : to_delete){\n            toDelete.add(i);\n        }\n        \n        delNodesPostOrder(root, toDelete, answer);\n        \n        if(!toDelete.contains(root.val)) {\n            answer.add(root);\n        }\n        \n        return answer;\n        \n    }\n    \n    private void delNodesPostOrder(TreeNode root , Set<Integer> toDelete, List<TreeNode> answer){\n        if(root==null){\n            return;\n        }\n        \n        delNodesPostOrder(root.left, toDelete, answer);\n        delNodesPostOrder(root.right, toDelete, answer);\n        \n        // When my children are getting deleted\n        if(root.left != null && toDelete.contains(root.left.val)){\n            root.left=null;\n        }\n        if(root.right != null && toDelete.contains(root.right.val)){\n            root.right=null;\n        }\n         \n        // When I am getting deleted.\n        if(toDelete.contains(root.val)){\n            if(root.left!=null){\n                answer.add(root.left);\n                root.left=null;    \n            }\n            if(root.right!=null){\n                answer.add(root.right);\n                root.right=null;\n            }\n        }\n    }\n}\n```
['Depth-First Search', 'Ordered Set']