JAVA non-recursive BFS solution
\n    public List<TreeNode> delNodes(TreeNode root, int[] to_delete) {\n        if (root == null) return new ArrayList<>();\n        \n        Set<TreeNode> res
```\n    public List<TreeNode> delNodes(TreeNode root, int[] to_delete) {\n        if (root == null) return new ArrayList<>();\n        \n        Set<TreeNode> resSet = new HashSet<>();\n        resSet.add(root);\n        if (to_delete.length == 0) return new ArrayList<>(resSet);\n\n        Set<Integer> toDelete = new HashSet<>();\n        for (int val : to_delete) toDelete.add(val);\n\n        Queue<TreeNode> q = new LinkedList<>();\n        q.offer(root);\n        while (!q.isEmpty()) {\n            TreeNode node = q.poll();\n            if (toDelete.contains(node.val)) {\n                resSet.remove(node);\n                if (node.left != null) resSet.add(node.left);\n                if (node.right != null) resSet.add(node.right);\n            }\n            if (node.left != null) {\n                q.offer(node.left);\n                if (toDelete.contains(node.left.val)) node.left = null;\n            }\n            if (node.right != null) {\n                q.offer(node.right);\n                if (toDelete.contains(node.right.val)) node.right = null;\n            }\n        }\n        return new ArrayList<>(resSet);\n    }\n```
[]