Before coding, decide what down[v] and up[v] store. For sum-of-distances, down[v] stores the total distance from to all nodes in its subtree. You also need size[v] to compute the shift formula.
For other problems, the state might be different. If you need max depth, down[v] stores the deepest node in 's subtree. If you need count of nodes satisfying a property, down[v] stores that count.
The rule: down[v] must capture enough information so that when you exclude one child and add the parent contribution, you can compute up[v] correctly. If down[v] alone is not enough, add auxiliary arrays.