Returns True if user is a group manager either for the group or any group.

def is_group_manager(user, group=None):
    """Returns True if user is a group manager either for the group or any group."""
    roles = get_user_roles(user)
    return any(x[1] == TenantRole.ROLE_GROUP_MANAGER and (not group or x[0] == group) for x in roles)