Implement dedupe(items, key=None) returning a list with only the first occurrence of each item, in original order. If key is given, two items are duplicates when key(item) is equal.
It must work for unhashable items (like dicts or lists) when a key that returns something hashable is supplied, and run in linear time.