public override Expression Visit([NotNull] Expression expression)
        {
            var currentExpression     = expression;
            var inExpressionOptimized =
                new EqualityPredicateInExpressionOptimizer().Visit(currentExpression);

            currentExpression = inExpressionOptimized;

            var negationOptimized1 =
                new PredicateNegationExpressionOptimizer()
                .Visit(currentExpression);

            currentExpression = negationOptimized1;

            var equalityExpanded =
                new EqualityPredicateExpandingVisitor().Visit(currentExpression);

            currentExpression = equalityExpanded;

            var negationOptimized2 =
                new PredicateNegationExpressionOptimizer()
                .Visit(currentExpression);

            currentExpression = negationOptimized2;

            var parameterDectector = new ParameterExpressionDetectingVisitor();

            parameterDectector.Visit(currentExpression);

            if (!parameterDectector.ContainsParameters &&
                !_useRelationalNulls)
            {
                var optimizedNullExpansionVisitor    = new RelationalNullsOptimizedExpandingVisitor();
                var relationalNullsExpandedOptimized = optimizedNullExpansionVisitor.Visit(currentExpression);
                if (optimizedNullExpansionVisitor.OptimizedExpansionPossible)
                {
                    currentExpression = relationalNullsExpandedOptimized;
                }
                else
                {
                    currentExpression = new RelationalNullsExpandingVisitor()
                                        .Visit(currentExpression);
                }
            }

            if (_useRelationalNulls)
            {
                currentExpression = new NotNullableExpression(currentExpression);
            }

            var negationOptimized3 =
                new PredicateNegationExpressionOptimizer()
                .Visit(currentExpression);

            currentExpression = negationOptimized3;

            return(currentExpression);
        }
        public override Expression Visit([NotNull] Expression expression)
        {
            var currentExpression = expression;
            var inExpressionOptimized =
                new EqualityPredicateInExpressionOptimizer().Visit(currentExpression);

            currentExpression = inExpressionOptimized;

            var negationOptimized1 =
                new PredicateNegationExpressionOptimizer()
                    .Visit(currentExpression);

            currentExpression = negationOptimized1;

            var equalityExpanded =
                new EqualityPredicateExpandingVisitor().Visit(currentExpression);

            currentExpression = equalityExpanded;

            var negationOptimized2 =
                new PredicateNegationExpressionOptimizer()
                    .Visit(currentExpression);

            currentExpression = negationOptimized2;

            var parameterDectector = new ParameterExpressionDetectingVisitor();
            parameterDectector.Visit(currentExpression);

            if (!parameterDectector.ContainsParameters
                && !_useRelationalNulls)
            {
                var optimizedNullExpansionVisitor = new RelationalNullsOptimizedExpandingVisitor();
                var relationalNullsExpandedOptimized = optimizedNullExpansionVisitor.Visit(currentExpression);
                if (optimizedNullExpansionVisitor.OptimizedExpansionPossible)
                {
                    currentExpression = relationalNullsExpandedOptimized;
                }
                else
                {
                    currentExpression = new RelationalNullsExpandingVisitor()
                        .Visit(currentExpression);
                }
            }

            if (_useRelationalNulls)
            {
                currentExpression = new NotNullableExpression(currentExpression);
            }

            var negationOptimized3 =
                new PredicateNegationExpressionOptimizer()
                    .Visit(currentExpression);

            currentExpression = negationOptimized3;

            return currentExpression;
        }