Improved model solution for common trie exercise.