* @lc app=leetcode id=124 lang=javascript
* [124] Binary Tree Maximum Path Sum
* Definition for a binary tree node.
* function TreeNode(val) {
* this.left = this.right = null;
function helper(node, payload) {
if (node === null) return 0;
const l = helper(node.left, payload);
const r = helper(node.right, payload);
node.val + Math.max(0, l) + Math.max(0, r),
return node.val + Math.max(l, r, 0);
var maxPathSum = function (root) {
if (root === null) return 0;