The second DFS propagates contributions from the parent side. For each node with parent , you compute up[v]: the answer contribution from everything outside 's subtree.
To get up[v], start with up[u] (what sees from its parent side), then add contributions from all of 's children except . This gives the full picture of the tree beyond its own subtree.
The root has no parent, so up[root] = 0. Every other node inherits and extends its parent's value. This pass also runs in time and uses space.