def decorate_depth(tree):
 for node in tree.levelorder(include_self=True):
  if (node.Parent is None):
   node.Score = 0
  else:
   node.Score = (node.Parent.Score + 1)
 return tree

def decorate_depth ( tree ) : for node in tree . levelorder ( include_self = True ) : if ( node . Parent is None ) : node . Score = 0 else : node . Score = ( node . Parent . Score + 1 ) return tree
this function maps the depth of each node on the tree .