code: public static URI getRelativePath(final URI relativePath) {
          final StringTokenizer tokenizer = new StringTokenizer(relativePath.toString(), URI_SEPARATOR);
          final StringBuilder buffer = new StringBuilder();
          if (tokenizer.countTokens() == 1) {
              return null;
          } else {
              while(tokenizer.countTokens() > 1) {
                  tokenizer.nextToken();
                  buffer.append("..");
                  buffer.append(URI_SEPARATOR);
              }
              return toURI(buffer.toString());
          }
      }
docs: Get relative path to base path.
  
  <p>For {@code foo/bar/baz.txt} return {@code ../../}</p>
  
  @param relativePath relative URI
  @return relative URI to base path, {@code null} if reference path was a single file