def METHOD_NAME(self, instances, headers, name):
    """
    Takes an array of flattened resource instances. If one of the resource fields contains a GeometryCollection,
    the instances will be grouped by geometry type and a shapefile file-like object will be returned for each
    geometry type.
    """
    if len(instances) > 0:
        geometry_fields = self.get_geometry_fieldnames(instances[0])
    else:
        return []
    shapefiles_for_export = []
    geos_datatypes_to_pyshp_types = {"str": "C", "datetime": "D", "float": "F"}
    for geometry_field in geometry_fields:
        features_by_geom_type = self.sort_by_geometry_type(instances, geometry_field)
        for geom_type, features in features_by_geom_type.items():
            if len(features) > 0:
                shp = BytesIO()
                shx = BytesIO()
                dbf = BytesIO()
                prj = BytesIO()
                if geom_type == "point":
                    writer = shapefile.Writer(shp=shp, shx=shx, dbf=dbf, shapeType=shapefile.MULTIPOINT)
                elif geom_type == "line":
                    writer = shapefile.Writer(shp=shp, shx=shx, dbf=dbf, shapeType=shapefile.POLYLINE)
                elif geom_type == "poly":
                    writer = shapefile.Writer(shp=shp, shx=shx, dbf=dbf, shapeType=shapefile.POLYGON)
                for header in headers:
                    try:
                        datatype = header.pop("datatype")
                    except KeyError:
                        pass
                    if header["fieldname"] != geometry_field:
                        writer.field(header["fieldname"], "C", 255)
                for feature in features:
                    shp_geom = self.convert_geom(feature[geometry_field])
                    if geom_type == "point":
                        writer.multipoint(shp_geom)
                    if geom_type == "line":
                        writer.line(shp_geom)
                    elif geom_type == "poly":
                        writer.poly(shp_geom)
                    for header in headers:
                        if header["fieldname"] not in feature:
                            feature[header["fieldname"]] = ""
                    writer.record(**feature)
                prj.write(
                    b'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],\
                    PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]'
                )
                writer.close()
                shapefiles_for_export += [
                    {"name": f"{name}_{geometry_field}_{geom_type}.shp", "outputfile": shp},
                    {"name": f"{name}_{geometry_field}_{geom_type}.dbf", "outputfile": dbf},
                    {"name": f"{name}_{geometry_field}_{geom_type}.shx", "outputfile": shx},
                    {"name": f"{name}_{geometry_field}_{geom_type}.prj", "outputfile": prj},
                ]
    return shapefiles_for_export