code: @Nullable
    public static Location getParent(Location location) {
      URI source = location.toURI();
  
      // If it is root, return null
      if ("/".equals(source.getPath())) {
        return null;
      }
  
      URI resolvedParent = URI.create(source.toString() + "/..").normalize();
      return location.getLocationFactory().create(resolvedParent);
    }
docs: Creates a {@link org.apache.twill.filesystem.Location} instance which represents the parent of the given location.
  
  @param location location to extra parent from.
  @return an instance representing the parent location or {@code null} if there is no parent.