code: protected static String normalizePath (String path) {
      int pathLen;
      do {
        pathLen = path.length();
        path = path.replaceAll("[^/]+/\\.\\./", "");
      } while (path.length() != pathLen);
      return path;
    }
docs: Normalizes the path, by removing {@code foo/..} pairs until the path contains no {@code ..}s.
  For example:
  {@code foo/bar/../baz/bif/../bonk.png} becomes {@code foo/baz/bonk.png} and
  {@code foo/bar/baz/../../bing.png} becomes {@code foo/bing.png}.