title: Going back one iteration in foreach loop in C#
body: <p>I have a <code>foreach</code> loop that iterates different levels of a <code>treeView</code> in C# that its simplified version looks like this:</p>
  
  <pre><code>foreach (TreeNode childNode in currentNode.Nodes)
  {
      if (!someCondition)
      {
          currentNode.Remove();                    
      }
  }   
  </code></pre>
  
  <p>but the problem is that when a node (for example from a list of node1, node2, node3 and node4) is removed the list becomes shorter and the <code>foreach</code> loop skips one iteration (for example, say if node2 was to be removed the list becomes node1, node3 and node4 and the next node that the <code>foreach</code> loop considers will be node4 instead of node3). This is because the framework is storing these nodes in an array/list so I would like to know if it is possible to make a <code>foreach</code> loop go back one iteration when I want to remove a node from the tree.</p>
  
  <p>I'm pretty new in .NET framework so your help is really appreciated.</p>