Changed Trie search logic.