Query..or(): complete with optimizations, reviewed but not tested