Implementing a trie structure