def METHOD_NAME(self):
    """ Pops the most last state off the history stack.
    If the history index points to the end of the stack, then it is
    adjusted; otherwise, the index is unaffected. If the stack is empty,
    the method raises an IndexError.
    Returns the popped state.
    """
    if len(self._history) == 0:
        raise IndexError("Unable to pop empty history stack.")
    if self._history_index == len(self._history) - 1:
        self._history_index -= 1
    return self._history.pop()