implementing autocomplete using a trie and using a treeset