Trie optimization