Count paths per branch

Hi, I need to count the paths in a tree, though divided by the upper level category. For the attached image, for instance, the looked-for answer would be:

[0]=7
[1]=7

(Used because keyboard doesn’t have the curly ones).

Tried tree statistics but it gives me the complete length of all the numbers throughout the tree. The length of each list is variable, and the number of lists is variable as well, so I’m more by the side of looking for a way to identify, group, and count all those paths that share numbre a, provided that

Tree = (a;n)

Is there any component that could be helpful solving this without further-extending the logic? It’s a big definition apart from this part, so I’m a little concerned with the time it would take solving.

Without a specific situation, you can trivially get paths count by doing:
List length > Trim tree > list length …

(Se hai tastiera italiana, puoi fare le parentesi graffe premendo Alt dx + shift + il tasto delle quadre… )