'Add two multivariate fractions ``f`` and ``g``.'

def add(f, g):

    if isinstance(g, DMP):
        (lev, dom, per, (F_num, F_den), G) = f.poly_unify(g)
        (num, den) = (dmp_add_mul(F_num, F_den, G, lev, dom), F_den)
    else:
        (lev, dom, per, F, G) = f.frac_unify(g)
        ((F_num, F_den), (G_num, G_den)) = (F, G)
        num = dmp_add(dmp_mul(F_num, G_den, lev, dom), dmp_mul(F_den, G_num, lev, dom), lev, dom)
        den = dmp_mul(F_den, G_den, lev, dom)
    return per(num, den)
