If the node is leaf then we just increment the no . of leaves under the subtree of a node
leaves [ a ] += 1 NEW_LINE else : NEW_LINE for i in v [ a ] : NEW_LINE INDENT if ( i [ 0 ] == par ) : NEW_LINE INDENT continue NEW_LINE DEDENT DEDENT