private static @Nullable FileLookup.LookupFile getClosestParent(String typed, Finder finder) {
    if (typed == null) return null;
    FileLookup.LookupFile lastFound = finder.find(typed);
    if (lastFound == null) return null;
    if (typed.isEmpty()) return lastFound;
    if (lastFound.exists()) {
      if (typed.charAt(typed.length() - 1) != File.separatorChar) return lastFound.getParent();
      return lastFound;
    }

    List<String> splits = finder.split(typed);
    StringBuilder fullPath = new StringBuilder();
    for (int i = 0; i < splits.size(); i++) {
      String each = splits.get(i);
      fullPath.append(each);
      if (i < splits.size() - 1) {
        fullPath.append(finder.getSeparator());
      }
      FileLookup.LookupFile file = finder.find(fullPath.toString());
      if (file == null || !file.exists()) return lastFound;
      lastFound = file;
    }

    return lastFound;
  }
private static @Nullable FileLookup.LookupFile getClosestParent(String typed, Finder finder)