Generalize traversal over whole expression to simplify distribute and squashMulId.