<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def join_state(self, state, history_index, concurrency_history_item):
 """ a utility function to join a state :param state: the state to join :param history_index: the index of the execution history stack in the concurrency history item for the given state :param concurrency_history_item: the concurrency history item that stores the execution history stacks of all children :return: """

        state.join()
        if state.backward_execution:
            self.backward_execution = True

        state.state_execution_status = StateExecutionStatus.INACTIVE
        # care for the history items
        if not self.backward_execution:
            state.concurrency_queue = None
            # add the data of all child states to the scoped data and the scoped variables
            state.execution_history.push_return_history_item(state, CallType.EXECUTE, self, state.output_data)
        else:
            last_history_item = concurrency_history_item.execution_histories[history_index].pop_last_item()
            assert isinstance(last_history_item, CallItem)