def _initialize_hierarchy(self):
        """ This function covers the whole initialization routine before executing a hierarchy state.
        :return:
        """
        logger.debug("Starting execution of {0}{1}".format(self, " (backwards)" if self.backward_execution else ""))

        # reset variables
        self.child_state = None
        self.last_error = None
        self.last_child = None
        self.last_transition = None

        if self.backward_execution:
            self.setup_backward_run()
        else:  # forward_execution
            self.setup_run()

        self.state_execution_status = StateExecutionStatus.WAIT_FOR_NEXT_STATE
        if self.backward_execution:
            last_history_item = self.execution_history.pop_last_item()
            assert isinstance(last_history_item, ReturnItem)
            self.scoped_data = last_history_item.scoped_data

        else:  # forward_execution
            self.execution_history.push_call_history_item(self, CallType.CONTAINER, self, self.input_data)
            self.child_state = self.get_start_state(set_final_outcome=True)
            if self.child_state is None:
                self.child_state = self.handle_no_start_state()