def remove_duplicates(list_, func=None):
    """ Remove all duplicates in a list.
        Set func to use another value than a self hash for determining if duplicate.
        Values must be hashable (If func is None) as they are passed through as dict keys. (Lists work but not Dicts) """
    if func is None:
        return list(dict.fromkeys(list_))
    else:
        return list({func(obj): obj for obj in list_}.values())