private void checkIfToolwindowMustBeRemoved(FacetType<?, ?> removedFacetType) {
        ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
        toolWindowManager.invokeLater(() -> {
          ProjectFacetManager facetManager = ProjectFacetManager.getInstance(project);
          if (facetManager.hasFacets(removedFacetType.getId())) {
            return;
          }

          for (FacetDependentToolWindow extension : getDependentExtensions(removedFacetType)) {
            ToolWindow toolWindow = toolWindowManager.getToolWindow(extension.id);
            if (toolWindow != null) {
              // check for other facets
              for (FacetType<?, ?> facetType : extension.getFacetTypes()) {
                if (facetManager.hasFacets(facetType.getId())) {
                  return;
                }
              }
              toolWindow.remove();
            }
          }
        });
      }
private void checkIfToolwindowMustBeRemoved(FacetType<?, ?> removedFacetType)