prevent infinite loop in middleware on circular group relations