Add extension method to delete nodes

We can't delete nodes while we're iterating over a node list because
that modifies the enumeration we're looping over. The new extension method
puts the nodes to delete in an array and then deletes them from their
parent node.