ExternalSystemNode<ExternalProjectPojo> (@NotNull ExternalProjectPojo project) { ExternalSystemNode<?> root = getRoot(); // Remove outdated projects. for (int i = root.getChildCount() - 1; i >= 0; i--) { ExternalSystemNode<?> child = root.getChildAt(i); ExternalSystemNodeDescriptor<?> descriptor = child.getDescriptor(); Object element = descriptor.getElement(); if (element instanceof ExternalProjectPojo pojo) { if (pojo.getPath().equals(project.getPath())) { if (!pojo.getName().equals(project.getName())) { pojo.setName(project.getName()); descriptor.setName(project.getName()); nodeChanged(child); } return (ExternalSystemNode<ExternalProjectPojo>)child; } } } ExternalProjectPojo element = new ExternalProjectPojo(project.getName(), project.getPath()); ExternalSystemNodeDescriptor<ExternalProjectPojo> descriptor = descriptor(element, myUiAware.getProjectIcon()); ExternalSystemNode<ExternalProjectPojo> result = new ExternalSystemNode<>(descriptor); insertNodeInto(result, root); return result; }