def compute_level(id, tree):
    """
    compute the level of an id in a tree

    """
    topic = tree[id]
    level = 0
    while (id != 0):
        level += 1
        id = topic['parent']
        topic = tree[id]
    return(level)