private string FindPredecessorRec(string wordPart, Node curNode,string carry)
{
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 FindPredecessorRec(newLabel, child, carry + curNode.Label);
return carry + curNode.Label;
}
else if (matches == curNode.Label.Length)
{
return carry + curNode.Label;
}
else return string.Empty;
}