code: private void insert(Geometry geom, GeometryIndex index, Geometry child) throws GeometryIndexNotFoundException {
  		if (index.hasChild() && geom.getGeometries() != null && geom.getGeometries().length > index.getValue()) {
  			insert(geom.getGeometries()[index.getValue()], index.getChild(), child);
  		} else if (checkType(geom, child)) {
  			if (geom.getGeometries() == null && index.getValue() == 0) {
  				geom.setGeometries(new Geometry[] { child });
  			} else if (geom.getGeometries() == null || index.getValue() < 0
  					|| index.getValue() > geom.getGeometries().length) {
  				throw new GeometryIndexNotFoundException("Geometry index out of bounds.");
  			} else {
  				Geometry[] result = new Geometry[geom.getGeometries().length + 1];
  				int count = 0;
  				for (int i = 0; i < result.length; i++) {
  					if (i == index.getValue()) {
  						result[i] = child;
  					} else {
  						result[i] = geom.getGeometries()[count];
  						count++;
  					}
  				}
  				geom.setGeometries(result);
  			}
  		} else {
  			throw new GeometryIndexNotFoundException("Cannot insert geometry at the requested location.");
  		}
  	}
docs: ------------------------------------------------------------------------