function invertTree(node) { if(!node) return; [node.left, node.right] = [node.right, node.left]; invertTree(node.left); invertTree(node.right); return node; }