ActionCallback (final Map<Object, Condition> adjusted, final Set<Object> originallySelected) { final ActionCallback result = new ActionCallback(); final Set<Object> allSelected = myUi.getSelectedElements(); Set<Object> toSelect = new HashSet<>(); for (Map.Entry<Object, Condition> entry : adjusted.entrySet()) { Condition condition = entry.getValue(); Object key = entry.getKey(); if (condition.value(key)) continue; for (final Object eachSelected : allSelected) { if (isParentOrSame(key, eachSelected)) continue; toSelect.add(key); } if (allSelected.isEmpty()) { toSelect.add(key); } } final Object[] newSelection = ArrayUtil.toObjectArray(toSelect); if (newSelection.length > 0) { myUi._select(newSelection, new TreeRunnable("UpdaterTreeState.processAjusted") { @Override public void perform() { final Set<Object> hangByParent = new HashSet<>(); processUnsuccessfulSelections(newSelection, o -> { if (myUi.isInStructure(o) && !adjusted.get(o).value(o)) { hangByParent.add(o); } else { addAdjustedSelection(o, adjusted.get(o), null); } return null; }, originallySelected); processHangByParent(hangByParent).notify(result); } }, false, true); } else { result.setDone(); } return result; }