Clean JavaScript solution
\nconst delNodes = (root, to_delete) => {\n  const set = new Set(to_delete);\n  const res = [];\n\n  const go = (node) => {\n    if (node == null) return node;\
```\nconst delNodes = (root, to_delete) => {\n  const set = new Set(to_delete);\n  const res = [];\n\n  const go = (node) => {\n    if (node == null) return node;\n    node.left = go(node.left);\n    node.right = go(node.right);\n\n    if (set.has(node.val)) {\n      if (node.left) res.push(node.left);\n      if (node.right) res.push(node.right);\n      return null;\n    }\n    return node;\n  };\n\n  if (!set.has(root.val)) res.push(root);\n  go(root);\n  return res;\n};\n```\n\n
['JavaScript']