Someone please help me look at my code. I do not know where is the problem.

'''

public class Solution {

public int maxPathSum(TreeNode root) {

int max = Integer.MIN_VALUE;

maxPathSum(root, max);

return max;

}

private int maxPathSum(TreeNode node, int max){

if(node == null) return 0;

int left = Math.max(0, maxPathSum(node.left, max));

int right = Math.max(0, maxPathSum(node.right, max));

max = Math.max(max, left + right +node.val);

return Math.max(left, right) + node.val;

}

}

'''