Return the set of associated Tenants for the given user and group.

def get_user_tenants(user, group):
    """Return the set of associated Tenants for the given user and group."""
    if user.is_active and user.is_authenticated():
        if user.is_superuser or is_group_manager(user, group.pk):
            return Tenant.objects.filter(group=group)
        else:
            return Tenant.objects.filter(group=group, tenantrole__user=user).distinct()
    else:
        return Tenant.objects.none()