For Tree Distances II, the up pass is simple. You already computed answer[1] = down[1] (the sum of distances from node to all others). Now propagate to children.
For each child of : answer[v] = answer[u] + n - 2 * size[v]. The - size[v] term accounts for 's subtree nodes getting closer. The + (n - size[v]) term accounts for outside nodes getting farther. You do not need prefix-suffix arrays here because the combine function is addition. Excluding one child's contribution is just subtraction.
This second DFS runs in time and uses space.