def collect(items, convert=(list, tuple), convert_to=tuple):
    """
    Converts a nested list/tuple/generator into a tuple. If no nested list/tuple/generator
    is found (or if multiple are found) then "items" is returned unchanged to the caller.
    Useful for generic functions.

    :param items: Target sequence
    :param convert: Tuple of types to convert into target type
    :param convert_to: Target type
    :return: The collected sequence
    """
    if len(items) == 1:
        head_item = head(items)
        if True in (isinstance(head_item, t) for t in convert):
            items = convert_to(*items)
        elif isgenerator(head(items)):
            items = convert_to(*items)
    return convert_to(items)