Function to count the frequency of node value present in the tree
def frequencyCounts ( root ) : NEW_LINE INDENT global mp NEW_LINE if ( root == None ) : NEW_LINE INDENT return NEW_LINE DEDENT mp [ root . key ] = mp . get ( root . key , 0 ) + 1 NEW_LINE frequencyCounts ( root . left ) NEW_LINE frequencyCounts ( root . right ) NEW_LINE DEDENT