code: function collapse_dots(path) {
    if (path === null) { return null; }
    var p = normPath(path);
    // Only /../ left to flatten
    var r = PARENT_DIRECTORY_HANDLER_RE;
    // We replace with $1 which matches a / before the .. because this
    // guarantees that:
    // (1) we have at most 1 / between the adjacent place,
    // (2) always have a slash if there is a preceding path section, and
    // (3) we never turn a relative path into an absolute path.
    for (var q; (q = p.replace(r, '$1')) != p; p = q) {};
    return p;
  }
docs: Normalizes its input path and collapses all . and .. sequences except for
  .. sequences that would take it above the root of the current parent
  directory.
  {@updoc
  $ collapse_dots('foo/../bar')
  # 'bar'
  $ collapse_dots('foo/./bar')
  # 'foo/bar'
  $ collapse_dots('foo/../bar/./../../baz')
  # 'baz'
  $ collapse_dots('../foo')
  # '../foo'
  $ collapse_dots('../foo').replace(EXTRA_PARENT_PATHS_RE, '')
  # 'foo'
  }