<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def step_mode(self, state_machine_id=None):
 """Set the execution mode to stepping mode. Transitions are only triggered if a new step is triggered """

        logger.debug("Activate step mode")

        if state_machine_id is not None:
            self.state_machine_manager.active_state_machine_id = state_machine_id

        self.run_to_states = []
        if self.finished_or_stopped():
            self.set_execution_mode(StateMachineExecutionStatus.STEP_MODE)
            self._run_active_state_machine()
        else:
            self.set_execution_mode(StateMachineExecutionStatus.STEP_MODE)