@Override
	public Expression convert(final Expression expression) {
		Calculable calc = expression.toCalculable(new RecursiveCalculableFactoryImpl());
		VariablesSet varSet = new VariablesSet(calc.getVariableNames());
		List<String> varKeySet = varSet.getKeySet();
		int size = (int) Math.pow(2, varKeySet.size());
		int prevLen = size;
		boolean[] prev = new boolean[prevLen];
		int counter = 0;
		
		while(varSet.notEnd()) {
			Map<String, Boolean> m = varSet.get();
			calc.with(m);
			Boolean val = calc.calculate();
			prev[counter] = val;
			counter++;
			varSet.moveToNext();
		}
		
		List<Boolean> values = new ArrayList<Boolean>();
		values.add(prev[0]);
		
		while (prevLen > 1) {
			boolean[] tmp = new boolean[prevLen - 1];
			
			for (int i = 0; i < prevLen - 1; i++) {
				tmp[i] = (prev[i] ^ prev[i + 1]);
			}
			
			values.add(tmp[0]);
			prevLen = prevLen - 1;
			prev = tmp;
		}
		
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.append("(");
		boolean first = true;
		int i = 0;
		
		for (Boolean value : values) {
			if (value) {
				String var = test(i, varKeySet);
				if (first) {
					first = false;
				} else {
					stringBuilder.append(' ' + Operators.XOR.REPRESENTATION + ' ');
				}
				stringBuilder.append(var);	
			}
			i++;
		}
		
		stringBuilder.append(")");
		String s = stringBuilder.toString();
		Parser parser = new RecursiveParserImpl();
		Expression expr = parser.parse(s);
		
		return expr;
	}