code: public Geometry getGeometry(Geometry geometry, GeometryIndex index) throws GeometryIndexNotFoundException {
  		if (index == null) {
  			return geometry;
  		}
  		if (index.hasChild()) {
  			if (geometry.getGeometries() != null && geometry.getGeometries().length > index.getValue()) {
  				return getGeometry(geometry.getGeometries()[index.getValue()], index.getChild());
  			}
  			throw new GeometryIndexNotFoundException("Could not match index with given geometry");
  		}
  		if (index.getType() == GeometryIndexType.TYPE_GEOMETRY && geometry.getGeometries() != null
  				&& geometry.getGeometries().length > index.getValue()) {
  			return geometry.getGeometries()[index.getValue()];
  		} else if (index.getType() == GeometryIndexType.TYPE_EDGE
  				&& (geometry.getCoordinates().length - 1) > index.getValue()) {
  			Geometry edge = new Geometry(Geometry.LINE_STRING, geometry.getSrid(), geometry.getPrecision());
  			edge.setCoordinates(new Coordinate[] { geometry.getCoordinates()[index.getValue()],
  					geometry.getCoordinates()[index.getValue() + 1] });
  			return edge;
  		} else if (index.getType() == GeometryIndexType.TYPE_VERTEX
  				&& geometry.getCoordinates().length > index.getValue()) {
  			Geometry point = new Geometry(Geometry.POINT, geometry.getSrid(), geometry.getPrecision());
  			point.setCoordinates(new Coordinate[] { geometry.getCoordinates()[index.getValue()] });
  			return point;
  		}
  		throw new GeometryIndexNotFoundException("Could not match index with given geometry");
  	}
docs: Given a certain geometry, get the (sub)geometry, edge or vertex the index points to. This only works if the index
  actually points to a sub-geometry, edge or vertex.
  
  @param geometry The geometry to search in.
  @param index The index that points to a sub-geometry within the given geometry or null for the complete geometry
  @return Returns the sub-geometry as itself, the edge as a linestring or the vertex as a point (only if they
  exist)
  @throws GeometryIndexNotFoundException Thrown if the sub-geometry, edge or vertex could not be found within the
  given geometry.