public void LineEdit_text_entered(string text) { AddLineBox.Text = string.Empty; TreeItem checkRoot = _root; var dirParts = text.Split("/"); foreach (var dirPart in dirParts) { TreeItem nest = null; TreeItem check = checkRoot.GetChildren(); while (check != null) { if (check.GetText(0) == dirPart) { nest = check; } check = check.GetNext(); } if (nest is null) { nest = _myTree.CreateItem(checkRoot); nest.SetText(0, dirPart); } checkRoot = nest; } }