private static int findCommonPathPrefixLength(@NotNull String path1, @NotNull String path2) {
    int end = -1;
    do {
      int beg = end + 1;
      int new_end = endOfToken(path1, beg);
      if (new_end != endOfToken(path2, beg) || !path1.substring(beg, new_end).equals(path2.substring(beg, new_end))) {
        break;
      }
      end = new_end;
    }
    while (end != path1.length());
    return Math.max(end, 0);
  }
private static int findCommonPathPrefixLength(@NotNull String path1, @NotNull String path2)