@Override public void visit(Exponentiation node) { Multiplication nodeMul; if (isSquare(node)) { nodeMul = new Multiplication(node.getLeft(), node.getLeft()); nx = nodeMul; if (opstor.OperationShouldBeReplaced(nodeMul)) { nx = new Variable(opstor.getReplacementID(nodeMul)); } } else { if (opstor.OperationShouldBeReplaced(node)) { nx = new Variable(opstor.getReplacementID(node)); System.out.println("Replacer: Node in Set: ( " + node.toString() + " ) ---> Replacing with " + opstor.getReplacementID(node)); } else { node.getLeft().accept(this); Expression lhs = nx; node.getRight().accept(this); Expression rhs = nx; nx = new Exponentiation(lhs, rhs); } } }