Rewrites every ArrayAdd() in expr whose terms are tensor products that
differ in at most one factor, so that
c1*(A x B) + c2*(C x B) becomes (c1*A + c2*C) x B.
Examples
k <- Symbol("k")
A <- MatrixSymbol("A", k, k); B <- MatrixSymbol("B", k, k); C <- MatrixSymbol("C", k, k)
collect_tensor_products(ArrayAdd(ArrayTensorProduct(A, B), ArrayTensorProduct(A, C)))
#> ArrayTensorProduct(A, B + C)