Additionally count elements only at top hierarchy
Fix hierarchy aggregation