def flatten(items, seqtypes=(list, tuple)):
    """Extract a single element if it is unnecessarily nested in a list"""
    while isinstance(items, seqtypes) and len(items) == 1:
        items = items[0]
    return items