private static int getParentPrefixOf(@NotNull String ancestor, @NotNull String path, boolean caseSensitive) {
    if (caseSensitive) {
      if (!path.startsWith(ancestor)) return -1;
    }
    else {
      if (!StringUtil.startsWithIgnoreCase(path, ancestor)) return -1;
    }

    if (ancestor.length() == path.length() ||
        path.charAt(ancestor.length()) == '/') {
      return ancestor.length() + 1;
    }

    // "/" and "C:/" roots
    if (!ancestor.isEmpty() && ancestor.charAt(ancestor.length() - 1) == '/') {
      return ancestor.length();
    }

    return -1;
  }
private static int getParentPrefixOf(@NotNull String ancestor, @NotNull String path, boolean caseSensitive)