private static bool equalsFunction(FunctionExpression left, FunctionExpression right)
        {
            if (left.Name != right.Name)
                return false;

            if (left.Arguments.Count != right.Arguments.Count)
                return false;

            for (int i = 0; i < left.Arguments.Count; i++)
            {
                if (!Equals(left.Arguments[i], right.Arguments[i]))
                    return false;
            }

            return true;
        }
        public static Expression TransformFunction(FunctionExpression expr, Func<Expression, Expression> transformation)
        {
            IList<Expression> arguments = new List<Expression>();

            foreach (Expression arg in expr.Arguments)
                arguments.Add(transformation(arg));

            return Function(expr.Name, arguments);
        }