Subtree sizes
Count the points in each branch, including its starting point. If the points stand for folders, you can tell how many folders will be copied when you copy a branch.
Count the vertex itself. Whenever a child finishes, add its total to the parent’s count.
Time is O(V).