Description
Each polynomial ring comes equipped with a
monomial ordering and this routine returns the lead (greatest) monomial and its coefficient. Recall that the default monomial order is the graded reverse lexicographic order.
i1 : R = QQ[a..d];

i2 : leadTerm (3*b*c^2d^31)
2
o2 = 3b*c
o2 : R

i3 : S = QQ[a..d, MonomialOrder => Lex]
o3 = S
o3 : PolynomialRing

i4 : leadTerm (3*b*c^2d^31)
2
o4 = 3b*c
o4 : S

Coefficients are included in the result:
i5 : R = ZZ[a..d][x,y,z];

i6 : leadTerm((a+b)*y^2 + (b+c)*x*z)
2
o6 = (a + b)y
o6 : R
