Phase 1: Tap two endpoints to trace a path through the tree.

A path visits connected nodes and sums their values. It can start and end anywhere, and it bends at most once. In this tree, what's the maximum sum any connected path can achieve?

Given a binary tree where each node holds an integer (positive, negative, or zero), find the maximum sum of any non-empty path -- where a “path” is a sequence of connected nodes that starts and ends anywhere and bends at most once.

FIG. 1 — THE TEACHING TREE
— Negative nodes near the root, positive cluster in the right subtree —

The optimal path can avoid the root entirely AND can include negative branches via clamping decisions -- and a “path” cannot fork twice, which means a node returns ONE side to its parent but considers BOTH sides for the global tracker.

FIG. 2 — TAP TWO ENDPOINTS FOR THE PATH YOU THINK HAS THE MAXIMUM SUM

Tap two nodes below. We'll compute the sum of the path between them. Can you find the maximum?