public Trie(List<String> targets_in ) { this.root = new TrieNode ('r'); // r means root this.currentNode = root; //build trie with target lines foreach(String line in targets_in) { foreach (char ch in line) { //if current node doesnt have the character, add it and traverse if (!currentNode.hasChildByID (ch)) { currentNode.addChild (ch); currentNode = currentNode.getChildByID (ch); } // else traverse the matching char branch else { currentNode = currentNode.getChildByID (ch); } } currentNode = root; } }