Trie implementation.