private static <T> int get_height(BinaryTree<T> n) {
        if(n == null) {
            return -1;
        }

        int l_height = get_height(n.getLeft());
        if(l_height == -2) {
            return -2; // left subtree is not balanced.
        }

        int r_height = get_height(n.getRight());
        if(r_height == -2) {
            return -2; // right subtree is not balanced.
        }

        if(Math.abs(l_height - r_height) > 1) {
            return -2; // current node n is not balanced.
        }
        return Math.max(l_height, r_height) + 1;
    }