Trie, refactoring