def METHOD_NAME(self):
    divisions_missing_territory_code = OrganisationDivision.objects.filter(
        territory_code__in=["", None]
    ).select_related("geography")
    for division in divisions_missing_territory_code:
        centre = division.geography.geography.centroid
        parents = (
            OrganisationDivision.objects.exclude(
                territory_code__in=["", None]
            )
            .filter(geography__geography__contains=centre)
            .filter(
                divisionset__organisation__slug__in=["parl", "europarl"]
            )
        )
        codes = {parent.territory_code for parent in parents}
        if len(codes) > 1:
            self.stdout.write(
                f"WARNING: {division} has more than one territory: {parents} / {codes}"
            )
            continue
        division.territory_code = parents.first().territory_code
        division.save()