public boolean isBalanced(TreeNode head){
        if(head==null){
            return true;
        }
        if(Math.abs(findMaxDistanceToLeaf(head.left)-findMaxDistanceToLeaf(head.right))<=1){
            if(isBalanced(head.right) && isBalanced(head.left)){
                return true;
            }
        }
        return false;
    }