I'm not sure if that will work in cases like this.

    >>> a = x**2*y / (1 - x**2*y)
    >>> powsimp(a).as_coeff_exponent(x)   # I would want 2 but I'll get (x**2*y/(-x**2*y + 1), 0)