def METHOD_NAME(coeffs, opt):
    """Handle composite domains, e.g.: ZZ[X], QQ[X], ZZ(X), QQ(X)."""
    numers, denoms = [], []
    for coeff in coeffs:
        numer, denom = coeff.as_numer_denom()
        numers.append(numer.expand())
        denoms.append(denom.expand())
    try:
        polys, _opt = _parallel_dict_from_expr(numers + denoms,
                                               build_options([], {}))  # XXX: sorting
        gens = _opt.gens
    except GeneratorsNeededError:
        return
    if opt.composite is None:
        if any(g.is_number and not g.is_transcendental for g in gens):
            return  # generators are number-like so lets better use EX
        all_symbols = set()
        for gen in gens:
            symbols = gen.free_symbols
            if all_symbols & symbols:
                return  # there could be algebraic relations between generators
            all_symbols |= symbols
    n = len(gens)
    k = len(polys)//2
    numers = polys[:k]
    denoms = polys[k:]
    if opt.field:
        fractions = True
    else:
        fractions, zeros = False, (0,)*n
        for denom in denoms:
            if len(denom) > 1 or zeros not in denom:
                fractions = True
                break
    coeffs = set()
    if not fractions:
        for numer, denom in zip(numers, denoms):
            denom = denom[zeros]
            for monom, coeff in numer.items():
                coeff /= denom
                coeffs.add(coeff)
                numer[monom] = coeff
    else:
        for numer, denom in zip(numers, denoms):
            coeffs.update(list(numer.values()))
            coeffs.update(list(denom.values()))
    rationals, reals = False, False
    for coeff in coeffs:
        if coeff.is_Rational:
            if not coeff.is_Integer:
                rationals = True
        elif coeff.is_Float:
            reals = True
            break
        else:
            raise NotImplementedError
    if reals:
        ground = RR
    elif rationals:
        ground = QQ
    else:
        ground = ZZ
    result = []
    if not fractions:
        domain = ground.inject(*gens)
        for numer in numers:
            for monom, coeff in numer.items():
                numer[monom] = ground.convert(coeff)
            result.append(domain(numer))
    else:
        domain = ground.inject(*gens).field
        for numer, denom in zip(numers, denoms):
            for monom, coeff in numer.items():
                numer[monom] = ground.convert(coeff)
            for monom, coeff in denom.items():
                denom[monom] = ground.convert(coeff)
            result.append(domain((numer, denom)))
    return domain, result