def METHOD_NAME(self, ballot, name, party=None):
    # exact search first
    try:
        return ballot.membership_set.get(person__name__iexact=name)
    except Membership.DoesNotExist:
        pass
    # fallback to a searcing on search vector field
    sq = SearchQuery(name, config="english")
    try:
        return ballot.membership_set.get(person__name_search_vector=sq)
    except (Membership.DoesNotExist, Membership.MultipleObjectsReturned):
        pass
    # get less specific - split the name and try and find a single match where at
    # least one of the names match
    query = " | ".join(name.split(" "))
    sq = SearchQuery(query, search_type="raw", config="english")
    try:
        return ballot.membership_set.get(person__name_search_vector=sq)
    except (Membership.DoesNotExist, Membership.MultipleObjectsReturned):
        pass
    if party:
        try:
            candidate = ballot.membership_set.get(
                party__name__icontains=party
            )
            self.stdout.write(
                "Found candidate by their party. Double check?"
            )
            self.stdout.write(
                f"Name: {name}\nParty: {party}\nBallot: {ballot.get_absolute_url()}"
            )
            return candidate
        except (
            Membership.DoesNotExist,
            Membership.MultipleObjectsReturned,
        ):
            pass
    # cant find this candidate
    url = (
        f"http://candidates.democracyclub.org.uk{ballot.get_absolute_url()}"
    )
    self.not_found.append(
        f"Cant find a membership for {name}. Check candidates at:\n{url}"
    )
    self.cant_find += 1
    return None