protected LiteralNode FindCoercionType(int index, bool nested)
        {
            if (index != 0 && index != 2)
            {
                return(null);
            }

            LiteralNode node = FindChild <LiteralNode>(OppositeSide(index)); // look at what the child operand is being compared to

            if (node == null && (Index == 0 || Index == 2))
            {
                node = Parent.FindChild <LiteralNode>(OppositeSide(this.Index)); // look at what the whole expression is being compared to
            }
            // if we don't find any literals in the area look, for a predicate expression that can drive the type coercion
            if (node == null)
            {
                PredicateNode predicate = FindChild <PredicateNode>(OppositeSide(index)); // look at what the child operand is being compared to
                if (predicate == null && (Index == 0 || Index == 2))
                {
                    predicate = Parent.FindChild <PredicateNode>(OppositeSide(this.Index)); // look at what the whole expression is being compared to
                }
                if (predicate != null && !nested)
                {
                    node = predicate.GetExpressionType(true);
                }
            }

            return(node);
        }
        internal override LiteralNode GetExpressionType()
        {
            PredicateNode p = FindChild <PredicateNode>(1);

            if (p != null)
            {
                return(p.GetExpressionType());
            }

            return(base.GetExpressionType());
        }
        protected Expression CreateChildExpression(ParameterExpression param, int index)
        {
            LiteralNode constant = FindChild <LiteralNode>(index);

            if (constant != null)
            {
                return(constant.CreateExpression());
            }

            Expression expression = CreateDereferenceExpression(param, index);

            if (expression != null)
            {
                return(expression);
            }

            PredicateNode predicate = FindChild <PredicateNode>(index);

            if (predicate != null)
            {
                return(predicate.CreateExpression(param));
            }

            FunctionNode function = FindChild <FunctionNode>(index);

            if (function != null)
            {
                return(function.CreateExpression(param));
            }

            // by not passing an index we pick up 'WHERE TRUE' etc
            LiteralNode literal = FindChild <LiteralNode>();

            if (literal != null)
            {
                return(literal.CreateExpression());
            }

            return(null);
        }