function depth(node, root): # distance from root down to node

   if node is root:
      return 0
   return 1 + depth(node.parent, root)

 function height(node):    # distance from node down to farthest lea
 f
   if length(node.children) == 0:
      return 0

   return 1 + max(height(child) for child in node.children)
