title: Finding the maximum path sum from root to n-ary leaf in a tree if a negative node restarts the sum from 0
body: <p>Given a n-ary tree with integer nodes, how to calculate the maximum sum inside a root to leaf path if any negative node resets the sum to 0. 
  For eg.,</p>
  
  <pre><code>      -3
      /  |   \
    2    4      1
   / \   |\    / | \
  1  -1  1 2  2 -1   3
      |    |     | \
      5   -2     4  7
  </code></pre>
  
  <p>Maximum sum inside each leaf to node path:</p>
  
  <p>{-3, 2, 1}  = 3</p>
  
  <p>{-3, 2, -1, 5} = 5</p>
  
  <p>{-3, 4, 1} = 5</p>
  
  <p>{-3, 4, 2, -2} = 6</p>
  
  <p>{-3, 1, 2} = 3</p>
  
  <p>{-3, 1, -1 ,4} = 4</p>
  
  <p>{-3, 1, -1 ,7} = 7</p>
  
  <p>{-3, 1, 3} = 4</p>
  
  <p>The path, {-3, 1, -1 ,7} = 7, will be the maximum sum for the given condition</p>