/// <summary>
 /// Enumerates all subexpressions related to this one
 /// </summary>
 /// <param name="expression"></param>
 /// <returns></returns>
 public static IEnumerable <Expression> GetOperands(this Expression expression)
 {
     if (expression is MutableExpression)
     {
         return(new List <Expression>(((MutableExpression)expression).Operands));
     }
     return(ExpressionMutatorFactory.GetMutator(expression).Operands);
 }
        /// <summary>
        /// Changes all operands
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="expression"></param>
        /// <param name="operands"></param>
        /// <param name="checkForChanges"></param>
        /// <returns>A potentially new expression with new operands</returns>
        public static T ChangeOperands <T>(this T expression, IList <Expression> operands, bool checkForChanges)
            where T : Expression
        {
            bool haveOperandsChanged = checkForChanges && HaveOperandsChanged(expression, operands);

            if (!haveOperandsChanged)
            {
                return(expression);
            }
            var mutableExpression = expression as IMutableExpression;

            if (mutableExpression != null)
            {
                return((T)mutableExpression.Mutate(operands));
            }
            return((T)ExpressionMutatorFactory.GetMutator(expression).Mutate(operands));
        }