code: public UnixPath removeTrailingSeparator() {
      if (!isRoot() && hasTrailingSeparator()) {
        return new UnixPath(permitEmptyComponents, path.substring(0, path.length() - 1));
      } else {
        return this;
      }
    }
docs: Removes trailing separator from path, unless it's root.