/// <summary>
        /// Visit invocation expressions to strip out invocations of the identity function.
        /// </summary>
        /// <param name="node">Expression to analyze and rewrite.</param>
        /// <returns>The original node if the invocation does not apply an identity function; otherwise, the operand of the identity function application.</returns>
        protected override Expression VisitInvocation(InvocationExpression node)
        {
            var visited = base.VisitInvocation(node);

            if (visited is InvocationExpression invoke && invoke.Expression.NodeType == ExpressionType.Parameter)
            {
                var target = (ParameterExpression)invoke.Expression;

                if (target.Name == Constants.IdentityFunctionUri)
                {
                    if (HasIdentitySignature(target.Type))
                    {
                        return(invoke.Arguments[0]);
                    }

                    throw new InvalidOperationException(
                              string.Format(
                                  CultureInfo.InvariantCulture,
                                  "Received invocation target type '{0}' in expression '{1}'; cannot call the identity function when argument type does not equal result type.",
                                  target.Type.ToCSharpStringPretty(),
                                  node.ToCSharpString(true)));
                }
            }

            return(visited);
        }