def set_node_text(dictnode, src):
    """
    Given a single dictnode and source code, fill in its 'text' attribute properly.
    The 'tail' of the children is filled in where appropriate.
    The node and its children must have a 'start' and 'end' integer property.

    Run this function on every node in the tree to completely fill out text and tail.
    """
    my = dictnode
    if my['children']:
        child = my['children'][0]
        my['text'] = src[my['start']:child['start']]
        for next_child in my['children'][1:]:
            child['tail'] = src[child['end']:next_child['start']]
            child = next_child
        child = my['children'][-1]
        child['tail'] = src[child['end']:my['end']]
    else:
        my['text'] = src[my['start']:my['end']]
