Is this safe? Erasing from the collection it iterates might be problematic. It's normally safer to collect entities to erase and bulk erase them after iterating. It's also faster to erase in bulk than individual entities.