def get_next_question(self, prev_answer=None):
    prev_question = self._current_question
    if (self._stop_command and (self._must_stop(prev_answer) or self._answers.stopped)):
        self._answers.toggle_stop(True)
        return None
    if prev_question:
        if (prev_question[ACTION] == ACTION_TEXT_QUESTION):
            self._answers.set(prev_question[ID], prev_answer)
        elif (prev_question[ACTION] == ACTION_YES_NO_QUESTION):
            yes = estr(prev_answer, prev_question[YES])
            no = estr(prev_answer, prev_question[NO])
            if (not (yes or no)):
                return Result(prev_question[ON_INVALID_CHOICE])
            self._answers.set(prev_question[ID], yes)
            level = (prev_question[ON_YES] if yes else prev_question[ON_NO])
            self._levels.change_level(level)
        elif (prev_question[ACTION] == ACTION_CHOICES_QUESTION):
            choice_id = prev_question[CHOICES].get(prev_answer)
            if (choice_id is None):
                return Result(prev_question[ON_INVALID_CHOICE])
            self._answers.set(prev_question[ID], choice_id)
            level = Level(prev_question[ON_CHOICES][choice_id])
            self._levels.change_level(level)
        elif (prev_question[ACTION] == ACTION_LIST_QUESTION):
            if (not estr(prev_answer, prev_question[STOP_COMMAND])):
                answers = self._answers.get(prev_question[ID])
                if (answers is None):
                    answers = []
                    self._answers.set(prev_question[ID], [])
                if prev_answer:
                    self._answers.set(prev_question[ID], [*answers, prev_answer])
                    answers.append(prev_answer)
                count = len(answers)
                max_answers = prev_question[MAX_ANSWERS]
                if (count < max_answers):
                    text = '{}{}'.format(self._current_question[TEXT], (self._current_question[START_NUMBER] + count))
                    return Result(text)
        elif (prev_question[ACTION] == ACTION_TEXT):
            self._answers.set(prev_question[ID], True)
    self._current_question = self._levels.get_next_question()
    if (self._current_question is not None):
        text = None
        if (self._current_question[ACTION] != ACTION_LIST_QUESTION):
            text = self._current_question[TEXT]
        else:
            text = '{}{}'.format(self._current_question[TEXT], self._current_question[START_NUMBER])
        self._answers.set(self._current_question[ID], None)
        return Result(text, (self._current_question[ACTION] == ACTION_TEXT))
def get_next_question(self, prev_answer=None):
    prev_question = self._current_question
    if (self._stop_command and (self._must_stop(prev_answer) or self._answers.stopped)):
        self._answers.toggle_stop(True)
        return None
    if prev_question:
        if (prev_question[ACTION] == ACTION_TEXT_QUESTION):
            self._answers.set(prev_question[ID], prev_answer)
        elif (prev_question[ACTION] == ACTION_YES_NO_QUESTION):
            yes = estr(prev_answer, prev_question[YES])
            no = estr(prev_answer, prev_question[NO])
            if (not (yes or no)):
                return Result(prev_question[ON_INVALID_CHOICE])
            self._answers.set(prev_question[ID], yes)
            level = (prev_question[ON_YES] if yes else prev_question[ON_NO])
            self._levels.change_level(level)
        elif (prev_question[ACTION] == ACTION_CHOICES_QUESTION):
            choice_id = prev_question[CHOICES].get(prev_answer)
            if (choice_id is None):
                return Result(prev_question[ON_INVALID_CHOICE])
            self._answers.set(prev_question[ID], choice_id)
            level = Level(prev_question[ON_CHOICES][choice_id])
            self._levels.change_level(level)
        elif (prev_question[ACTION] == ACTION_LIST_QUESTION):
            if (not estr(prev_answer, prev_question[STOP_COMMAND])):
                answers = self._answers.get(prev_question[ID])
                if (answers is None):
                    answers = []
                    self._answers.set(prev_question[ID], [])
                if prev_answer:
                    self._answers.set(prev_question[ID], [*answers, prev_answer])
                    answers.append(prev_answer)
                count = len(answers)
                max_answers = prev_question[MAX_ANSWERS]
                if (count < max_answers):
                    text = '{}{}'.format(self._current_question[TEXT], (self._current_question[START_NUMBER] + count))
                    return Result(text)
        elif (prev_question[ACTION] == ACTION_TEXT):
            self._answers.set(prev_question[ID], True)
    self._current_question = self._levels.get_next_question()
    if (self._current_question is not None):
        text = None
        if (self._current_question[ACTION] != ACTION_LIST_QUESTION):
            text = self._current_question[TEXT]
        else:
            text = '{}{}'.format(self._current_question[TEXT], self._current_question[START_NUMBER])
        self._answers.set(self._current_question[ID], None)
        return Result(text, (self._current_question[ACTION] == ACTION_TEXT))