def _flatten(arr):
    """Return a deeply flattened list copy of nested list, tuple, or set."""
    flat = []
    if type(arr) in (list, tuple, set):
        for el in arr:
            flat.extend(_flatten(el))
    else:
        flat.append(arr)
    return flat