Every path in the original tree passes through some centroid in the decomposition. If a path does not pass through the current centroid, it lies entirely within one component after removal. You will process it in a deeper recursion level.
This means you can count all paths by processing paths through each centroid.
At centroid , count paths from to all nodes in its subtree, then combine paths from different subtrees. No path is missed. You avoid double-counting because each path is counted exactly once: at its lowest common ancestor in the decomposition tree. This is the foundation of path-counting algorithms.