for key in hash_dict:
    for item in hash_dict[key]:
        if item in seen:
            repeated.add(item)
else:
    seen.add(item)
for key in hash_dict:
    ret[key] = ret.get(key, [])
for item in hash_dict[key]:
    if item not in repeated:
        ret[key].append(item)
return ret
Check for duplicate elements in lists in a dictionary in Python