implementation of Trie