code: private static void getArealGeometry(ArrayList<Polygon> polygones, Geometry geometry) {
           for (int i = 0; i < geometry.getNumGeometries(); i++) {
              Geometry subGeom = geometry.getGeometryN(i);
              if(subGeom instanceof Polygon){
                  polygones.add((Polygon) subGeom);
              }
              else if (subGeom instanceof GeometryCollection){
                  getArealGeometry(polygones, subGeom);
              }
          }
      }
docs: Filter polygon from a geometry
  @param polygones
  @param geometry