After both passes, every node has two values. down[v] captures everything in 's subtree. up[v] captures everything outside 's subtree. The final answer for node as root combines these two.
For sum-of-distances, the formula is answer[v] = down[v] + up[v]. For max-depth problems, it might be answer[v] = max(down[v], up[v]). The combine function depends on the problem, but the two-pass structure stays the same.
This gives you all answers in total time and space. No recomputation needed.