public IExpressionNode Simplify() { LeftOperand = LeftOperand.Simplify(); RightOperand = RightOperand.Simplify(); if (!LeftOperand.ContainsVariable() && !RightOperand.ContainsVariable()) { return(new Constant(this.Evaluate(null))); } else if (!LeftOperand.ContainsVariable() && RightOperand.ContainsVariable()) { if (LeftOperand.Evaluate(null) == 0) { return(new Constant(0)); } if (LeftOperand.Evaluate(null) == 1) { return(RightOperand.DeepCopy()); } } else if (LeftOperand.ContainsVariable() && !RightOperand.ContainsVariable()) { if (RightOperand.Evaluate(null) == 0) { return(new Constant(0)); } if (RightOperand.Evaluate(null) == 1) { return(LeftOperand.DeepCopy()); } } return(this); }