public void updateProjects(Collection<? extends DataNode<ProjectData>> toImport) {
    List<String> toImportPaths = ContainerUtil.map(toImport, pd -> pd.getData().getLinkedExternalProjectPath());
    Collection<String> orphanProjects = ContainerUtil.subtract(ContainerUtil.mapNotNull(myNodeMapping.entrySet(),
         entry -> entry.getValue() instanceof ProjectNode ? entry.getKey() : null), toImportPaths);
    for (DataNode<ProjectData> each : toImport) {
      final ProjectData projectData = each.getData();
      final String projectPath = projectData.getLinkedExternalProjectPath();

      ExternalSystemNode<?> projectNode = findNodeFor(projectPath);

      if (projectNode instanceof ProjectNode) {
        doMergeChildrenChanges(projectNode, new ProjectNode(myExternalProjectsView, each));
      }
      else {
        ExternalSystemNode<?> node = myNodeMapping.remove(projectPath);
        if (node != null) {
          SimpleNode parent = node.getParent();
          if (parent instanceof ExternalSystemNode) {
            ((ExternalSystemNode<?>)parent).remove(projectNode);
          }
        }

        projectNode = new ProjectNode(myExternalProjectsView, each);
        myNodeMapping.put(projectPath, projectNode);
      }
      if (toImport.size() == 1) {
        TreeUtil.expand(myTree, 1);
      }
      doUpdateProject((ProjectNode)projectNode);
    }

    //remove orphan projects from view
    for (String orphanProjectPath : orphanProjects) {
      ExternalSystemNode<?> projectNode = myNodeMapping.remove(orphanProjectPath);
      if (projectNode instanceof ProjectNode) {
        SimpleNode parent = projectNode.getParent();
        if (parent instanceof ExternalSystemNode) {
          ((ExternalSystemNode<?>)parent).remove(projectNode);
          updateUpTo(projectNode);
        }
      }
    }
  }
public void updateProjects(Collection<? extends DataNode<ProjectData>> toImport)