public static @Nullable String getParent(@NotNull String path) {
    int length = path.length();
    int lastSeparator = PathUtilRt.lastSeparatorIndex(path, length-1);
    if (lastSeparator < 0) return null;
    if (lastSeparator == length - 1) lastSeparator = PathUtilRt.lastSeparatorIndex(path, length - 2);
    if (lastSeparator < 0) return null;

    if (PathUtilRt.startsWithSeparatorSeparator(path)) {
      // a UNC path
      int slashIndex = nextSeparatorIndex(path, 2);
      if (lastSeparator > 1 && slashIndex != -1 && slashIndex <= lastSeparator && PathUtilRt.isWindowsUNCRoot(path, slashIndex)) {
        int prevSeparator = PathUtilRt.lastSeparatorIndex(path, lastSeparator - 1);
        if (prevSeparator > 1) {
          return path.substring(0, lastSeparator);
        }
      }
      return null;
    }

    if (lastSeparator == 2 && startsWithWindowsDrive(path)) {
      // a DOS path
      return path.substring(0, 3);
    }

    return path.substring(0, lastSeparator == 0 ? 1 : lastSeparator);
  }
public static @Nullable String getParent(@NotNull String path)