another implementation for trie with hashmap