public void DeleteRec(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()))
{
if (newLabel == child.Label)
{
if (child.SubNodes.Count == 0)
{
curNode.SubNodes.Remove(child);
return;
}
}
DeleteRec(newLabel, child);
}
}
}