void (@NotNull JpsElementContainerEx modified) { final Collection<JpsElementChildRole<?>> roles = new ArrayList<>(); synchronized (myDataLock) { roles.addAll(myElements.keySet()); } for (JpsElementChildRole<?> role : roles) { applyChanges(role, modified); } roles.clear(); synchronized (modified.getDataLock()) { roles.addAll(modified.getElementsMap().keySet()); } synchronized (myDataLock) { roles.removeAll(myElements.keySet()); } for (JpsElementChildRole<?> role : roles) { applyChanges(role, modified); } }