// invert binary tree using recursive function
function invertTree(node) {
if (node && node.left) {
let left = node.left;
node.left = node.right;
node.right = left;
invertTree(node.right);
invertTree(node.left);
}
return node;
}