def METHOD_NAME(domain, location_ids, user_id_to_exclude):
    """
    Gets all the location ids where a `CommCareUser` is assigned to one of the `location_ids`.
    This list excludes the given `user_id`.
    """
    other_user_loc_ids = (
        UserES()
        .domain(domain)
        .mobile_users()
        .NOT(filters.doc_id(user_id_to_exclude))
        .location(location_ids)
        .values_list('assigned_location_ids', flat=True)
    )
    # If more than one user shares a location, it will give a list of lists
    # So need to make sure to flatten these
    return set(flatten_list(other_user_loc_ids))