private int countLevel(TreeNode n) {
        if (n == null) {
            return 0;
        } else {
            int leftCount = countLevel(n.left);
            int rightCount = countLevel(n.right);
            if (Math.abs(leftCount - rightCount) > 1) {
                result = false;
            }
            return 1 + Math.max(leftCount, rightCount);
        }
    }