def METHOD_NAME(self):
    if not self._ended:
        raise Exception("Can't create doc before END status was recevived.")
    if self._doc is not None:
        return self._doc
    doc = self._items[self._get_key((None, None, None))]
    seen = set()
    # this puts all in the original order
    for identity in self._order:
        key = self._get_key(identity)
        section, _, _ = identity
        sectionKey = self._get_key((section, None, None))
        sectionDoc = self._items[sectionKey]
        check = self._items[key]
        if self._results_by:
            if not sectionDoc["checks"]:
                clusterlen = self._max_cluster_by_index + 1
                if self._results_by != "*check":
                    # + 1 for rests bucket
                    clusterlen += 1
                sectionDoc["checks"] = [[] for _ in range(clusterlen)]
            index = check["clustered"]["index"]
            if index is None:
                # last element collects unclustered
                index = -1
            sectionDoc["checks"][index].append(check)
        else:
            sectionDoc["checks"].append(check)
        if sectionKey not in seen:
            seen.add(sectionKey)
            doc["sections"].append(sectionDoc)
    self._doc = doc
    return doc