private ResultType2 _isBalanced(TreeNode root) {
        if (root == null) {
            return (new ResultType2(0, true));
        }
        
        ResultType2 left = _isBalanced(root.left);
        ResultType2 right = _isBalanced(root.right);
        
        int depth = Math.max(left.depth, right.depth);
        boolean balanced = left.balanced && right.balanced && (Math.abs(left.depth - right.depth) <= 1);
        return (new ResultType2(depth, balanced));
    }