public static void main(String[] args) {
    // Create balanced tree
    int[] array = {0, 1, 2, 3, 5, 6, 7, 8, 9, 10};
    TreeNode root = TreeNode.createMinimalBST(array);

    System.out.println("Is balanced? " + isBalanced(root));

    root.insertInOrder(4); // Add 4 to make it unbalanced

    System.out.println("Is balanced? " + isBalanced(root));
  }
 public static void main(String[] args) {
   int[] array = {5, 3, 6, 1, 9, 11};
   TreeNode root = new TreeNode(20);
   for (int a : array) {
     root.insertInOrder(a);
   }
   TreeNode n1 = root.find(1);
   TreeNode n9 = root.find(9);
   TreeNode ancestor = commonAncestor(root, n1, n9);
   System.out.println(ancestor.data);
 }