### manipulation of multivariate polynomial

Hello,
I have an expression that comes from expanding a product of polynomials in one variable each. For demonstration purposes I'm using the Symbolic Ring but the question is not specific to it:

```
sage: var('a,b')
(a, b)
sage: ex=(1+a+a^2+a^3)*(1+b+b^2+b^3)
sage: ex.expand()
a^3*b^3 + a^3*b^2 + a^2*b^3 + a^3*b + a^2*b^2 + a*b^3 + a^3 + a^2*b + a*b^2 + b^3 + a^2 + a*b + b^2 + a + b + 1
```

Is there a nice way to get a new expression from that which has only exponents <=3 when a and b are seen as identical? The above product would then yield:

```
a^3 + a^2*b + a*b^2 + b^3 + a^2 + a*b + b^2 + a + b + 1
```

that is, for example a*b^3 is removed because it has combined exponent 4.

I'm looking for a way to achieve this without writing a loop that goes through all terms.