isNodeBalanced(node) {
    let isBalanced = true;

    if (node.left !== null && node.right !== null) {
      isBalanced = Math.abs(node.left.height - node.right.height) <= 1;
    } else if (node.right !== null && node.left === null) {
      isBalanced = node.right.height < 2;
    } else if (node.left !== null && node.right === null) {
      isBalanced = node.left.height < 2;
    }
    return isBalanced;
  }
Verifies if the given node is balanced.