trees :: Trie :: search_node
Returns null
if no node matches string
.
# Search a node by a key or prefix
#
# Returns `null` if no node matches `string`.
private fun search_node(string: nullable Object): nullable TrieNode[E] do
if string == null then return null
string = string.to_s
var children = root.children
var node = null
for i in [0..string.length[ do
var c = string.chars[i]
if children.has_key(c) then
node = children[c]
children = node.children
else
node = null
break
end
end
return node
end
lib/trees/trie.nit:161,2--180,4