Dyanmic groups for both location AND sublocation

Does anyone know how to create a dynamic location group which could contain both location and sublocations (from that location) matching certain criterias?

Example:
We have the following locations/sublocations
ACME-a-city1
ACME-a-city1->foo
ACME-a-city1->other
ACME-a-city2
ACME-b-city1
ACME-b-city1->bar
ACME-b-city1->foo
ACME-b-city1->other
ACME-b-city2
ACME-b-city2->smth
ACME-b-city2->other

I want to create a dynamic location group which contains all listed above with name starting with ‘ACME-b-’, both locations and sublocations - but NOT anything starting with ‘ACME-A’

Means the dyn group should contain only
ACME-b-city1
ACME-b-city1->bar
ACME-b-city1->baz
ACME-b-city1->other
ACME-b-city2
ACME-b-city2->smth
ACME-b-city2->other

Setting the criteria for ‘name starts with’ does not work; sublocations are missed then.
Setting the criteria for ‘name contains/equals/… other’ does not work either; then also ‘ACME-a-city1-> other’ is matched