I have TreeNode object from my TreeView which is the currently selected Node. I would like to traverse this node to find its highest level parent and get some information from it (namely the data in its Tag variable). 
How could I easily do this while keeping my inNode still equal to what it was then the function was passed it?
private void openNodeWindow(TreeNode inNode)
{
    // Find the top level window type this is in.
    TreeNode curNode = inNode; 
    WindowType topLevelType = WindowType.NO_WINDOW;
    // As long as there is a parent to this Node
    while (curNode.Parent != null && 
        // As long as that parent has a specified window type
        (WindowType)curNode.Parent.Tag != WindowType.NO_WINDOW)
    {
        topLevelType = (WindowType)curNode.Tag;
        curNode = curNode.Parent;
    }
    // Do stuff with the topLevelType variable now
    // Also having inNode set back to what it was originally
}
 
     
    