#NEWLINE# def _mostfunc( lhs , func , X = None ) : #NEWLINE# #INDENT# 'Returns the term in lhs which contains the most of the\n    func-type things e.g. log(log(x)) wins over log(x) if both terms appear.\n\n    ``func`` can be a function (exp, log, etc...) or any other SymPy object,\n    like Pow.\n\n    Examples\n    ========\n\n    >>> from sympy.solvers.bivariate import _mostfunc\n    >>> from sympy.functions.elementary.exponential import exp\n    >>> from sympy.utilities.pytest import raises\n    >>> from sympy.abc import x, y\n    >>> _mostfunc(exp(x) + exp(exp(x) + 2), exp)\n    exp(exp(x) + 2)\n    >>> _mostfunc(exp(x) + exp(exp(y) + 2), exp, x)\n    exp(x)\n    >>> _mostfunc(exp(x) + exp(exp(y) + 2), exp, x)\n    exp(x)\n    >>> _mostfunc(x, exp, x) is None\n    True\n    >>> _mostfunc(exp(x) + exp(x*y), exp, x)\n    exp(x)\n    ' #NEWLINE# fterms = [ tmp for tmp in lhs . atoms ( func ) if ( ( not X ) or ( X . is_Symbol and ( X in tmp . free_symbols ) ) or ( ( not X . is_Symbol ) and tmp . has ( X ) ) ) ] #NEWLINE# if ( len ( fterms ) == 1 ) : #NEWLINE# #INDENT# return fterms [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if fterms : #NEWLINE# #INDENT# return max ( list ( ordered ( X ) ) , key = ( lambda x : x . count ( func ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# return None