def METHOD_NAME(cls, user_or_token):
    """Can only delete a stream from a user if none of the user's groups
    require that stream for membership.
    """
    from .group_joins import GroupStream
    return (
        DBSession()
        .query(cls)
        .filter(sa.literal(user_or_token.is_admin))
        .join(User, cls.user)
        .outerjoin(Group, User.groups)
        .outerjoin(
            GroupStream,
            sa.and_(
                GroupStream.group_id == Group.id,
                GroupStream.stream_id == cls.stream_id,
            ),
        )
        .group_by(cls.id)
        # no OR here because Users will always be a member of at least one
        # group -- their single user group.
        .having(sa.func.bool_and(GroupStream.stream_id.is_(None)))
    )