from typing import OrderedDict


def unique(iterable, key=None):
    """Return unique elements of an iterable."""
    if key:
        odict = OrderedDict()
        for element in iterable:
            odict.setdefault(key(element), element)
        return list(odict.values())
    else:
        return list(OrderedDict.fromkeys(iterable))