RadixTree.Tree.LookupRec C# (CSharp) Method

LookupRec() private method

look for a word in the tree begining at the current node
private LookupRec ( string wordPart, Node curNode ) : bool
wordPart string
curNode Node
return bool
        private bool LookupRec(string wordPart, Node curNode)
        {
            var matches = MatchingConsecutiveCharacters(wordPart, curNode);

            if ((matches == 0) || (curNode == _root) ||
                ((matches > 0) && (matches < wordPart.Length) && (matches >= curNode.Label.Length)))
            {

                var newLabel = wordPart.Substring(matches, wordPart.Length - matches);
                foreach (var child in curNode.SubNodes)
                    if (child.Label.StartsWith(newLabel[0].ToString()))
                        return LookupRec(newLabel, child);

                return false;
            }
            else if (matches == curNode.Label.Length)
            {
                return true;
            }
            else return false;
        }