I don’t think you can proceed like this.
Group A (and its children) will always be above Group B (an its children).
Instead of this you could try to create supplementary groups, place them interleave and link origin points together.
From top to bottom:
- Group ATop (with the 2 top A layers)
- Group BTop (with 2 top B layers)
- Group ABottom (with bottom layer of group A)
- Group BBottom (with the lower B layer)
Link origins of ATop and ABottom
Link origins of BTop and BBottom
Now animate only ATop and BTop for rotation (or other transforms), their XBottom will follow them 