Okay, here is a solution but it only goes through 2 levels (children and grandchildren).
In E13 copied down, I put this array formula
Formula:
=IFERROR(INDEX($A$7:$A$15, SMALL(IF($C$7:$C$15="",ROW($C$7:$C$15)-ROW($C$7)+1),ROWS($A$1:A1))),"")
...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.
In F13 copied down
Formula:
=COUNTIF($C$7:$C$15,E13)+COUNTIF($C$7:$C$15,INDEX($A$7:$A$15,MATCH(E13,$C$7:$C$15,0)))
In G13 copied down
Formula:
=SUMIF($A$7:$A$15,E13,$B$7:$B$15)+SUMIF($C$7:$C$15,E13,$B$7:$B$15)+SUMIF($C$7:$C$15, INDEX($A$7:$A$15,MATCH(E13,$C$7:$C$15,0)),$B$7:$B$15)
Bookmarks