public void updateAndSelect(PackagingElementNode<?> node, final List<? extends PackagingElement<?>> toSelect) {
    myArtifactsEditor.queueValidation();
    myTreeStructure.clearCaches();
    List<PackagingElementNode<?>> nodesToSelect = Collections.synchronizedList(new ArrayList<>(toSelect.size()));
    myStructureTreeModel.invalidate(node, true)
      .thenAsync(result -> TreeUtil.promiseVisit(myTree, (path) -> {
        Object nodeObject = TreeUtil.getLastUserObject(path);
        if (nodeObject instanceof PackagingElementNode && ContainerUtil.intersects(((PackagingElementNode<?>)nodeObject).getPackagingElements(), toSelect)) {
          nodesToSelect.add((PackagingElementNode)nodeObject);
        }
        return TreeVisitor.Action.CONTINUE;
      }))
      .thenAsync(result -> Promises.collectResults(ContainerUtil.map(nodesToSelect, nodeToSelect -> myStructureTreeModel.promiseVisitor(nodeToSelect))))
      .thenAsync(visitors -> TreeUtil.promiseSelect(myTree, visitors.stream()));
  }
public void updateAndSelect(PackagingElementNode<?> node, final List<? extends PackagingElement<?>> toSelect)