def _flatten_as_set(lst):
    """Flatten a list of lists removing duplicates."""
    seen = set()
    result = []
    for f in lst:
        for lab in f.find_labels():
            if lab not in seen:
                result.append(lab)
                seen.add(lab)
    return result