This is a basic datastructure of a prefix tree also known as a trie.