Tree: Depth-First Search - Binary Tree Maximum Path Sum
Examine the following recursive code snippet for maximum path sum. Which line contains the subtle bug that causes incorrect results on trees with negative values?
```python
def max_gain(node):
nonlocal max_sum
if not node:
return 0
left_gain = max_gain(node.left)
right_gain = max_gain(node.right)
price_newpath = node.val + left_gain + right_gain
max_sum = max(max_sum, price_newpath)
return node.val + left_gain + right_gain
```
