I am trying to go through each and every single treenode in a treeview.

I want to be able to return a treenode, or null, if a specific object has been found. how can I do this? I feel like i've lost all my knowledge!


private TreeNode GetObjectFromTreeView(TreeNode startingNode, MyObject objectToMatch)
{
foreach(TreeNode currentNode in startingNode.Nodes)
{
if (currentNode.Tag != null && currentNode.Tag.GetType() == typeof(MyObject))
{
return currentNode;
}

return this.GetObjectFromTreeView(currentNode, objectToMatch);

}


return null;
}