static IEnumerable <Key> Equal <Key>(BTreeBase <Key, Key> sourceCollection, BinaryExpression binExp)
#if WINDOWS_PHONE
            where Key : new()
#endif
        {
            SessionBase          session   = sourceCollection.Session;
            CompareByField <Key> comparer  = sourceCollection.Comparer as CompareByField <Key>;
            Expression           leftSide  = binExp.Left;
            Expression           rightSide = binExp.Right;
            object rightValue = GetRightValue(leftSide, rightSide);

            if (leftSide.NodeType == ExpressionType.Parameter)
            {
                Key key = (Key)rightValue;
                if (key != null)
                {
                    BTreeSetIterator <Key> itr = sourceCollection.Iterator();
                    itr.GoTo(key);
                    while (sourceCollection.Comparer.Compare(itr.Current(), key) == 0)
                    {
                        yield return(itr.Next());
                    }
                }
            }
            else
            {
                if (comparer != null)
                {
                    MemberExpression returnedEx = null;
#if WINDOWS_PHONE || WINDOWS_UWP
                    Key key = (Key)Activator.CreateInstance(typeof(Key));
#else
                    Key key = (Key)FormatterServices.GetUninitializedObject(typeof(Key));
#endif
                    if (comparer.FieldsToCompare == null)
                    {
                        comparer.SetupFieldsToCompare();
                    }
                    DataMember dataMember = comparer.FieldsToCompare[0];
                    if (rightValue != null && HasIndexablePropertyOnLeft <Key>(leftSide, sourceCollection, dataMember, out returnedEx))
                    {
                        MemberExpression propExp  = (MemberExpression)returnedEx;
                        MemberInfo       property = propExp.Member;
                        dataMember.SetMemberValueWithPossibleConvert(key, rightValue);
                        BTreeSetIterator <Key> itr = sourceCollection.Iterator();
                        itr.GoTo(key);
                        Key current = itr.Current();
                        while (current != null && comparer.CompareField(dataMember, key, current, 0) == 0)
                        {
                            yield return(current);

                            current = itr.Next();
                        }
                    }
                }
            }
        }
        static IEnumerable <Key> And <Key>(BTreeBase <Key, Key> sourceCollection, BinaryExpression binExp)
#if WINDOWS_PHONE
            where Key : new()
#endif
        {
            CompareByField <Key> comparer = sourceCollection.Comparer as CompareByField <Key>;
            int indexNumberOfFields       = comparer.FieldsToCompare.Length;

#if WINDOWS_PHONE || WINDOWS_UWP
            Key key = (Key)Activator.CreateInstance(typeof(Key));
#else
            Key key = (Key)FormatterServices.GetUninitializedObject(typeof(Key));
#endif
            while (binExp.NodeType == ExpressionType.AndAlso)
            {
                BinaryExpression leftExpr   = (BinaryExpression)binExp.Left;
                BinaryExpression rightExpr  = (BinaryExpression)binExp.Right;
                DataMember       dataMember = comparer.FieldsToCompare[--indexNumberOfFields];
                object           rightValue = GetRightValue(rightExpr.Left, rightExpr.Right);
                dataMember.SetMemberValueWithPossibleConvert(key, rightValue);
                binExp = leftExpr;
                if (binExp.NodeType == ExpressionType.Equal)
                {
                    dataMember = comparer.FieldsToCompare[--indexNumberOfFields];
                    rightValue = GetRightValue(binExp.Left, binExp.Right);
                    dataMember.SetMemberValueWithPossibleConvert(key, rightValue);
                }
            }
            BTreeSetIterator <Key> itr = sourceCollection.Iterator();
            itr.GoTo(key);
            Key current = itr.Current();
            while (current != null && comparer.Compare(key, current) == 0)
            {
                yield return(current);

                current = itr.Next();
            }
        }
        static IEnumerable <Key> LessThan <Key>(BTreeBase <Key, Key> sourceCollection, BinaryExpression binExp)
#if WINDOWS_PHONE
            where Key : new()
#endif
        {
            SessionBase          session    = sourceCollection.Session;
            Expression           leftSide   = binExp.Left;
            Expression           rightSide  = binExp.Right;
            object               rightValue = GetRightValue(leftSide, rightSide);
            CompareByField <Key> comparer   = sourceCollection.Comparer as CompareByField <Key>;

            if (leftSide.NodeType == ExpressionType.Parameter)
            {
                Key key = (Key)rightValue;
                if (key != null)
                {
                    BTreeSetIterator <Key> itr = sourceCollection.Iterator();
                    if (itr.GoTo(key))
                    {
                        while (itr.Previous() != null)
                        {
                            yield return(itr.Current());
                        }
                    }
                }
            }
            else
            {
                if (comparer != null)
                {
                    //if we were able to create a hash from the right side (likely)
                    MemberExpression returnedEx = null;
#if WINDOWS_PHONE || WINDOWS_UWP
                    Key key = (Key)Activator.CreateInstance(typeof(Key));
#else
                    Key key = (Key)FormatterServices.GetUninitializedObject(typeof(Key));
#endif
                    if (comparer.FieldsToCompare == null)
                    {
                        comparer.SetupFieldsToCompare();
                    }
                    DataMember dataMember = comparer.FieldsToCompare[0];
                    if (rightValue != null && HasIndexablePropertyOnLeft <Key>(leftSide, sourceCollection, dataMember, out returnedEx))
                    {
                        //cast to MemberExpression - it allows us to get the property
                        MemberExpression propExp  = (MemberExpression)returnedEx;
                        MemberInfo       property = propExp.Member;
                        foreach (DataMember member in comparer.FieldsToCompare.Skip(1))
                        {
                            if (member.GetTypeCode == TypeCode.String)
                            {
                                member.SetMemberValue(key, "");
                            }
                        }
                        dataMember.SetMemberValueWithPossibleConvert(key, rightValue);
                        BTreeSetIterator <Key> itr = sourceCollection.Iterator();
                        itr.GoTo(key);
                        var v = itr.Current();
                        if (v == null)
                        {
                            v = itr.Previous();
                        }
                        while (v != null && comparer.CompareField(dataMember, key, v, 0) == 0)
                        {
                            v = itr.Previous();
                        }
                        while (v != null)
                        {
                            yield return(v);

                            v = itr.Previous();
                        }
                    }
                    else if (leftSide.NodeType == ExpressionType.Call)
                    {
                        // don't know yet how to handle TODO

                        /*MethodCallExpression expression = leftSide as MethodCallExpression;
                         * Trace.Out.WriteLine("Method: " + expression.Method.Name);
                         * Trace.Out.WriteLine("Args: ");
                         * foreach (var exp in expression.Arguments)
                         * sourceCollection where */
                    }
                }
            }
        }