TODO: Improve memory efficiency of trie.