void () { if (!oldElement.equals(newElement.get()) || forceRemapping.get()) { removeMapping(oldElement, childNode, newElement.get()); Object newE = newElement.get(); if (!isNodeNull(newE)) { createMapping(newE, childNode); } NodeDescriptor<?> parentDescriptor = getDescriptorFrom(parentNode); if (parentDescriptor != null) { parentDescriptor.setChildrenSortingStamp(-1); } } if (index == null) { int selectedIndex = -1; if (TreeBuilderUtil.isNodeOrChildSelected(myTree, childNode)) { selectedIndex = parentNode.getIndex(childNode); } if (childNode.getParent() instanceof DefaultMutableTreeNode parent) { if (myTree.isExpanded(new TreePath(parent.getPath()))) { if (parent.getChildCount() == 1 && parent.getChildAt(0) == childNode) { insertLoadingNode(parent, false); } } } Object disposedElement = getElementFor(childNode); removeNodeFromParent(childNode, selectedIndex >= 0); disposeNode(childNode); adjustSelectionOnChildRemove(parentNode, selectedIndex, disposedElement); result.setResult(null); } else { elementToIndexMap.remove(getElementFromDescriptor(childDesc.get())); updateNodeChildren(childNode, pass, null, false, canSmartExpand, forceUpdate, true, true) .doWhenDone(() -> result.setResult(null)); } }