code: private void addGeometry(Geometry geom) {
          if (geom != null) {
              if (geom instanceof GeometryCollection) {
                  List<Geometry> toUnitTmp = new ArrayList<Geometry>(geom.getNumGeometries());
                  for (int i = 0; i < geom.getNumGeometries(); i++) {
                      toUnitTmp.add(geom.getGeometryN(i));
                      feedDim(geom.getGeometryN(i));
                  }
                  toUnite.addAll(toUnitTmp);
              } else {
                  toUnite.add(geom);
                  feedDim(geom);
              }
          }
      }
docs: Add geometry into an array to accumulate
  @param geom