Modifying a structure while iterating over it is generally dangerous (so we have assertions to catch it), though in this case it was probably fine, because we stopped iterating as soon as we made the modification.