<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def assign_texts(node, words, next_idx=0):
 """ Recursively assign the words to nodes by finding and assigning strings to the leaves of a tree in left to right order. """

    if len(node.children) == 0:
        node.text = words[next_idx]
        return next_idx + 1
    else:
        for child in node.children:
            next_idx = assign_texts(child, words, next_idx)
        return next_idx