I am struggling to figure out the time complexity of the following problem (this is not homework, just something I came up with and can't understand).
Suppose you have an arbitrary tree. The algorithm is such that for every node in the tree you have to run some O(1) operation as many times as that node's number of leaf descendants. So, in the example tree below, we would run 2 operations for node A and 6 operations for the root node R.
Let's say you have n nodes, the tree is of depth d, and you may use any other notation necessary. What is the complexity?
I can't quite wrap my head around this. Surely it is less than O(n^2) but how do I approach this? Thank you!
Edit: leaf descendant of a node is a descendant that does not have any children. A descendant is a node reachable by repeated proceeding from parent to child (doesn't matter if it's an internal or a leaf node)

Rshould be 9?