public Tensor transform(Tensor tensor) {
SubstitutionIterator iterator = new SubstitutionIterator(tensor, traverseGuide);
Tensor current;
while ((current = iterator.next()) != null) {
if (current instanceof Product)
iterator.unsafeSet(expandProduct((Product) current, transformations));
else if (ExpandUtils.isExpandablePower(current)) {
Sum sum = (Sum) current.get(0);
int exponent = ((Complex) current.get(1)).intValue();
if (exponent == -1)
continue;