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

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