def METHOD_NAME(state, prefix):
    out_arcs = graph[state].items()
    if len(out_arcs) == 0:
        word = b''.join(prefix)
        vocabulary.append(word)
        if len(vocabulary) > max_num_words:
            raise RuntimeError("Number of words in vocabulary exceeds limit ({}), stopping".format(max_num_words))
        return
    prefix.append(None)
    for in_label, next_state in out_arcs:
        prefix[-1] = alphabet[in_label - 1]
        METHOD_NAME(next_state, prefix)
    prefix.pop()