_end = '_end_'

def make_trie(*words):
    root = dict()
for word in words:
    current_dict = root
for letter in word:
    current_dict = current_dict.setdefault(letter, {})
current_dict = current_dict.setdefault(_end, _end)
return root
Remove a dictionary key if it is a substring in any other key