JavaScript recursion
\n/**\n * @param {TreeNode} root\n * @param {number} sum\n * @return {number}\n */\nvar pathSum = function(root, sum) {\n  if (!root) return 0;\n  return (\n   
```\n/**\n * @param {TreeNode} root\n * @param {number} sum\n * @return {number}\n */\nvar pathSum = function(root, sum) {\n  if (!root) return 0;\n  return (\n    pathSumOnlyStart(root, sum) +\n    pathSum(root.left, sum) +\n    pathSum(root.right, sum)\n  );\n};\n\nconst pathSumOnlyStart = (root, sum) => {\n  if (!root) return 0;\n  const self = root.val === sum ? 1 : 0;\n  return (\n    self +\n    pathSumOnlyStart(root.left, sum - root.val) +\n    pathSumOnlyStart(root.right, sum - root.val)\n  );\n};\n```
['Recursion', 'JavaScript']