Avoid altering the `pending_nodes` list while iterating over it.