Handling nested groups with cyclic references