def match_piecewise(candidates: set, symbol: str, sep: str='::') -> set:
    """
    Match the requested symbol reverse piecewise (split on ``::``) against the candidates.
    This allows you to under-specify the base namespace so that ``"MyClass"`` can match ``my_namespace::MyClass``

    Args:
        candidates: set of possible matches for symbol
        symbol: the symbol to match against
        sep: the separator between identifier elements

    Returns:
        set of matches
    """
    piecewise_list = set()
    for item in candidates:
        split_symbol = symbol.split(sep)
        split_item = item.split(sep)

        split_symbol.reverse()
        split_item.reverse()

        min_length = len(split_symbol)

        split_item = split_item[:min_length]

        if split_symbol == split_item:
            piecewise_list.add(item)

    return piecewise_list