Tag each node under root with the appropriate depth.

def tagAttributes_while(fdef_master_list,root):
    '''Tag each node under root with the appropriate depth. '''
    depth = 0
    current = root
    untagged_nodes = [root]
    while untagged_nodes:
        current = untagged_nodes.pop()
        for x in fdef_master_list:
            if jsName(x.path,x.name) == current['name']:
                current['path'] = x.path
        if children in current:
            for child in children:
                child["depth"] = depth
                untagged_nodes.append(child)
        if depth not in current:
            current["depth"] = depth
            depth += 1
    return root