private static @Nullable String findPathToRemap(Set<String> files, VirtualFile contentRoot) {
    final Comparator<String> comparator = Comparator.comparingInt(o -> StringUtil.countChars(o, '/'));
    final List<String> sortedFiles = ContainerUtil.reverse(ContainerUtil.sorted(files, comparator));
    final List<String> suspects = sortedFiles.subList(0, Math.min(3, sortedFiles.size()));
    String pathToRemap = null;
    for (String suspect : suspects) {
      String[] pathParts = suspect.split("/");
      String path = "";
      String oldValue = pathToRemap;
      for (String part : pathParts) {
        path += part + "/";
        final String relPath = StringUtil.substringAfter(suspect, path);
        if (relPath != null && contentRoot.findFileByRelativePath(relPath) != null) {
          pathToRemap = StringUtil.substringBeforeLast(path, "/");
          break;
        }
      }
      if (oldValue != null && !oldValue.equals(pathToRemap)) {
        pathToRemap = null;
        break;
      }
    }
    return pathToRemap;
  }
private static @Nullable String findPathToRemap(Set<String> files, VirtualFile contentRoot)