def METHOD_NAME(self, data, many):
    if many:
        if data["items"]:
            if isinstance(data, InstrumentedList) or isinstance(data, list):
                self.context["total"] = len(data)
                return data
            else:
                self.context["total"] = data["total"]
        else:
            self.context["total"] = 0
            data = {"items": []}
        return data["items"]
    return data