'Trims a given number of steps from the end of the sequence.'

def _trim_steps(self, num_steps):

    steps_trimmed = 0
    while (self._events and (steps_trimmed < num_steps)):
        if (self._events[(-1)].event_type == PerformanceEvent.TIME_SHIFT):
            if ((steps_trimmed + self._events[(-1)].event_value) > num_steps):
                self._events[(-1)] = PerformanceEvent(event_type=PerformanceEvent.TIME_SHIFT, event_value=((self._events[(-1)].event_value - num_steps) + steps_trimmed))
                steps_trimmed = num_steps
            else:
                steps_trimmed += self._events[(-1)].event_value
                self._events.pop()
        else:
            self._events.pop()
