To query the path from to , use this algorithm: While and are in different chains, move the deeper one up. Query the segment from the deeper node to its chain head. Then jump to the parent of the chain head. When both nodes are finally in the same chain, query the segment between them.
This processes chain segments. Each segment tree query takes time, so the total time is per path query. You maintain the maximum value seen across all queried segments.
Space complexity is for the data structures used.