collect coefficients



Hello,
Is there a command in maxima, parallel to the
collect(expression,variable) in maple ?
It should present the expression as a generalized polynomial in powers
of the variable.
For example:
collect(x^b+a*x^b+x)^2=
(a + 1)^2*x^(2*b) + 2*(a + 1)*x^(b + 1) + x^2

In sage (that uses maxima), the problem is solved by using Python programming:
def collect(f,x):
    return sum(c*x^i for c, i in f.coeffs(x))


Is it possible to program something of this sort within maxima ?

Thanks,
Eli