@Nullable
  private static Pair<PsiDirectory, String> findLongestExistingDirectoryAndItsPath(@NotNull PsiManager manager, @NotNull String path) {
    PsiDirectory directory = null;
    // find longest existing path
    while (path.length() > 0) {
      VirtualFile file = LocalFileSystem.getInstance().findFileByPath(path);
      if (file != null) {
        directory = manager.findDirectory(file);
        if (directory == null) {
          return null;
        }
        break;
      }

      if (StringUtil.endsWithChar(path, '/')) {
        path = path.substring(0, path.length() - 1);
        if (SystemInfo.isWindows && path.length() == 2 && OSAgnosticPathUtil.startsWithWindowsDrive(path)) {
          return null;
        }
      }

      int index = path.lastIndexOf('/');
      if (index == -1) {
        // nothing to do more
        return null;
      }

      path = path.substring(0, index);
    }
    return Pair.create(directory, path);
  }
@Nullable
  private static Pair<PsiDirectory, String> findLongestExistingDirectoryAndItsPath(@NotNull PsiManager manager, @NotNull String path)