cleaned code for trie.py