Trie for autocomplete in javascript