How iterate over Diagram Nodes after deleting one via removeNodeData

Hello. I am trying to iterate over the Nodes belonging to my Diagram object.
I do so in the following way:

 var itr = ticketMasterDiagram.nodes;
     while (itr.next()) {
      //perform my node-by-node task
  }

I call a routine that iterates over Diagram.nodes in the above way immediately after calling removeNodeData on the model belonging to my Diagram on one of the nodes. It is important that this change is reflected in the collection returned by nodes that I iterate over subsequently.

When I do it this way, I get the following error:

Error: Collection was modified during iteration: Set(Node)#234
Perhaps you should iterate over a copy of the collection,
or you could collect items to be removed from the collection after the iteration.

How can I make a copy of the nodes set which has the node which I delete removed from it, and doesn’t raise an error?

For example, if I make use the copy() method from the Set class here:
http://gojs.net/latest/api/symbols/Set.html

it makes a shallow copy of each Node. But presumbaly, as I advance the iterator with next I will run into trouble when next points to the Node that has been deleted? I suppose perhaps not if I make the copy after the Node deletion?

Thank you!

So I had the wrong idea of what the error message was communicating.

What I was doing was calling removeNodeData in the middle of iterating across the Set of Node objects denoted by that traversed by the iterator returned by the call to model.nodes. This clearly is a problematic thing to do, so I simply moved the deletion of the node to happening after I iterated through all the Nodes saving the Node Data I needed to find through iteration in the middle of the loop to be used immediately after for deletion.