Function to sum of heights of individual Nodes Uses Inorder traversal
def getTotalHeightUtil ( root ) : NEW_LINE INDENT global sum NEW_LINE if ( root == None ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT lh = getTotalHeightUtil ( root . left ) NEW_LINE rh = getTotalHeightUtil ( root . right ) NEW_LINE h = max ( lh , rh ) + 1 NEW_LINE sum = sum + h NEW_LINE return h NEW_LINE DEDENT def getTotalHeight ( root ) : NEW_LINE INDENT getTotalHeightUtil ( root ) NEW_LINE return sum NEW_LINE DEDENT