def METHOD_NAME(self, *, block: Block, height: int) -> Block:
    """
    Given a block, returns its ancestor at a specific height.
    Uses the height index if the block is in the best blockchain, or search iteratively otherwise.
    """
    assert height < block.get_height(), (
        f"ancestor height must be lower than the block's height: {height} >= {block.get_height()}"
    )
    metadata = block.get_metadata()
    if not metadata.voided_by and (ancestor := self._tx_storage.get_transaction_by_height(height)):
        assert isinstance(ancestor, Block)
        return ancestor
    return _get_ancestor_iteratively(block=block, ancestor_height=height)