private static @NotNull Icon getContentRootIcon(@NotNull PsiDirectory directory) {
    VirtualFile file = directory.getVirtualFile();

    Project project = directory.getProject();
    ProjectFileIndex projectFileIndex = ProjectFileIndex.getInstance(project);
    VirtualFile sourceRoot = projectFileIndex.getSourceRootForFile(file);
    if (sourceRoot != null) {
      return IconUtil.getIcon(sourceRoot, 0, project);
    }

    return IconUtil.getIcon(file, 0, project);
  }
private static @NotNull Icon getContentRootIcon(@NotNull PsiDirectory directory)