code: public static ParsedPath toDirectory(String rawPath) {
          final String path = rawPath.trim();
          if (path.isEmpty()) {
              // TODO: Is This legal?
              return EMPTY;
          }
          if ("/".equals(path)) {
              // TODO: Is this special case needed?
              return ROOT;
          }
  
          final boolean startsWithDelimiter = path.startsWith("/");
  
          // Remove the trailing delimiter.
          // This allows us to treat paths that end with a delimiter as paths to the last directory on the path.
          // i.e. path/to and path/to/ are the same - a path with 2 elements: 'path' and 'to'.
          final List<String> pathElements = splitPath(path, false);
          return new ParsedPath(startsWithDelimiter, pathElements);
      }
docs: Create a path that is expected to represent a path to a directory.
  This means that if the path ends with a delimiter '/', it is considered the same as if it didn't.
  i.e. path/to and path/to/ are considered the same - a path with 2 elements: 'path' and 'to'.
  
  @param rawPath Path to parse.
  @return A {@link ParsedPath} out of the given path.
  @throws IllegalArgumentException If any element along the path is empty.