int dfs(TreeNode root) {
        if (root == null)
            return 0;
        int left = dfs(root.left);
        int right = dfs(root.right);
        if (root.left != null && root.left.val == root.val)
            left++;
        else
            left = 0;
        if (root.right != null && root.right.val == root.val)
            right++;
        else
            right = 0;
        max = Math.max(max, left + right);
        return Math.max(left, right);
    }
Why Did you create this class? what does it do?
src/problems/medium/LongestUnivaluePath.java