def run(self):
        """ This defines the sequence of actions that are taken when the hierarchy is executed. A hierarchy state
        executes all its child states recursively. Principally this code collects all input data for the next
        child state, executes it, stores its output data and determines the next state
        based on the outcome of the child state.
        :return:
        """

        try:
            self._initialize_hierarchy()
            while self.child_state is not self:
                # print("hs1", self.name)
                self.handling_execution_mode = True
                execution_mode = singleton.state_machine_execution_engine.handle_execution_mode(self, self.child_state)

                # in the case of starting the sm from a specific state not the transitions define the logic flow
                # but the the execution_engine.run_to_states; thus, do not alter the next state in this case
                if not self._start_state_modified:
                    # check if e.g. the state machine was paused and the next state was modified (e.g. removed)
                    self.check_if_child_state_was_modified()

                self.handling_execution_mode = False
                if self.state_execution_status is not StateExecutionStatus.EXECUTE_CHILDREN:
                    self.state_execution_status = StateExecutionStatus.EXECUTE_CHILDREN

                # print("hs2", self.name)

                self.backward_execution = False
                if self.preempted:
                    if self.last_transition and self.last_transition.from_outcome == -2:
                        logger.debug("Execute preemption handling for '{0}'".format(self.child_state))
                    else:
                        break
                elif execution_mode == StateMachineExecutionStatus.BACKWARD:
                    break_loop = self._handle_backward_execution_before_child_execution()
                    if break_loop:
                        break
                # This is only the case if this hierarchy-state is started in backward mode,
                # but the user directly switches to the forward execution mode
                if self.child_state is None:
                    break

                # print("hs3", self.name)

                self._execute_current_child()

                if self.backward_execution:
                    # print("hs4", self.name)
                    break_loop = self._handle_backward_execution_after_child_execution()
                    if break_loop:
                        # print("hs4.1", self.name)
                        break
                else:
                    # print("hs5", self.name)
                    break_loop = self._handle_forward_execution_after_child_execution()
                    if break_loop:
                        break
                # print("hs6", self.name)
            return self._finalize_hierarchy()

        except Exception as e:
            logger.error("{0} had an internal error: {1}\n{2}".format(self, str(e), str(traceback.format_exc())))
            self.output_data["error"] = e
            self.state_execution_status = StateExecutionStatus.WAIT_FOR_NEXT_STATE
            self.child_state = None
            self.last_child = None
            return self.finalize(Outcome(-1, "aborted"))
This defines the sequence of actions that are taken when the hierarchy is executed. A hierarchy state
        executes all its child states recursively. Principally this code collects all input data for the next
        child state, executes it, stores its output data and determines the next state
        based on the outcome of the child state.
        :return: