def treeify(node, tree_id, pos=1, level=0):
    'Set tree properties in memory.\n    '
    node['tree_id'] = tree_id
    node['level'] = level
    node['left'] = pos
    for child in node.get('children', []):
        pos = treeify(child, tree_id, pos=(pos + 1), level=(level + 1))
    pos = (pos + 1)
    node['right'] = pos
    return pos
Set tree properties in memory.
def treeify(node, tree_id, pos=1, level=0):
    '\n    '
    node['tree_id'] = tree_id
    node['level'] = level
    node['left'] = pos
    for child in node.get('children', []):
        pos = treeify(child, tree_id, pos=(pos + 1), level=(level + 1))
    pos = (pos + 1)
    node['right'] = pos
    return pos