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
converts the list to an array and enumerates over the array.