from typing import Iterable


def strip_unnecessary_url_parts(urls: Iterable, parameters: bool = False, fragments: bool = True) -> set:
    """Strip unnecessary URL parts.

    :param urls: URLs to be stripped (can be any Iterable).
    :param parameters: If ``True``, strips URL query parameters (always start with a ``?``) from the URL.
    :param fragments: If ``True``, strips URL fragments (introduced with ``#``), except for relevant fragments using Google's hash bang syntax.
    :return: Iterable of URLs, optionally without (query) parameters.
    """
    stripped = set()
    for url in urls:
        if parameters:
            url = url.split("?")[0]
        if fragments:
            if not ("#!" in url):   # Check if Google hash bang syntax is used
                url = url.split("#")[0]
        stripped.add(url)

    return stripped