Refactor: Pulling out TrieNode methods into its class.