def is_repetition(self, count: int = 3) -> bool:
    """
    Checks if the current position has repeated 3 (or a given number of)
    times.

    Unlike :func:`~chess.Board.can_claim_threefold_repetition()`,
    this does not consider a repetition that can be played on the next
    move.

    Note that checking this can be slow: In the worst case, the entire
    game has to be replayed because there is no incremental transposition
    table.
    """
    # Fast check, based on occupancy only.
    maybe_repetitions = 1
    for state in reversed(self.stack):
        if state.occupied == self.occupied:
            maybe_repetitions += 1
            if maybe_repetitions >= count:
                break
    if maybe_repetitions < count:
        return False

    # Check full replay.
    transposition_key = self._transposition_key()
    switchyard = []

    try:
        while True:
            if count <= 1:
                return True

            if len(self.move_stack) < count - 1:
                break

            move = self.pop()
            switchyard.append(move)

            if self.is_irreversible(move):
                break

            if self._transposition_key() == transposition_key:
                count -= 1
    finally:
        while switchyard:
            self.push(switchyard.pop())

    return False