def METHOD_NAME(
    self, query: Query, group_ids_to_exclude: Set[int]
) -> Set[int]:
    """
    Given a Query and the group ids to exclude for any project
    this query touches, returns the intersection of the group ids
    from the replacements and the group ids this Query explicitly
    queries for, if any.
    Eg.
    - The query specifically looks for group ids: {1, 2}
    - The replacements on the projects require exclusion of groups: {1, 3, 4}
    - The query only needs to exclude group id 1
    """
    groups_in_query = get_object_ids_in_query_ast(query, self.__groups_column)
    if groups_in_query:
        group_ids_to_exclude = group_ids_to_exclude.intersection(groups_in_query)
    return group_ids_to_exclude