private static boolean areLastRootsTheSame(List<DetectedProjectRoot> result, JavaModuleSourceRoot root) {
    if (result.size() < THRESHOLD) return false;

    List<DetectedProjectRoot> lastItems = result.subList(result.size() - THRESHOLD, result.size());
    for (DetectedProjectRoot item : lastItems) {
      if (!(item instanceof JavaModuleSourceRoot oldRoot)) return false;
      if (!FileUtil.filesEqual(oldRoot.getDirectory(), root.getDirectory()) || !oldRoot.getPackagePrefix().equals(root.getPackagePrefix())
          || !oldRoot.getRootTypeName().equals(root.getRootTypeName())) {
        return false;
      }
    }
    return true;
  }
private static boolean areLastRootsTheSame(List<DetectedProjectRoot> result, JavaModuleSourceRoot root)