private static Polynomial toPolynomial(Multiplication term, Variable x) {
NavigableMap<NaturalNumber, Expression> coeffs = new TreeMap();
TerminationPattern c = Numbers.constant("c");
TerminationPattern n = Numbers.constant("n");
ExpressionPattern cxn = new Multiplication(c, new Exponentiation(x, n));
if (cxn.matches(term)) {
coeffs.put((NaturalNumber) n.hit(), c.hit());
} else {
throw new IllegalArgumentException("Illegal polynomial term: " + term);
}