[docs]defunion(*x:Sequence,duplicate_method:DUPLICATE_METHOD="first")->list:""" Identify the union of values in multiple sequences, while preserving the order of the first (or last) occurence of each value. Args: x: Zero, one or more sequences of interest containing hashable values. We ignore missing values as defined by :py:meth:`~biocutils.is_missing_scalar.is_missing_scalar`. duplicate_method: Whether to take the first or last occurrence of each value in the ordering of the output. If first, the first occurrence in the earliest sequence of ``x`` is reported; if last, the last occurrence in the latest sequence of ``x`` is reported. Returns: Union of values across all ``x``. """nargs=len(x)ifnargs==0:return[]output=[]present=set()defhandler(f):ifnotis_missing_scalar(f)andfnotinpresent:output.append(f)present.add(f)ifduplicate_method=="first":forainx:forfina:handler(f)else:forainreversed(x):forfinreversed(a):handler(f)output.reverse()returnoutput