Implementing trie in typescript