moving nested predicate constructs outside for cleaner interface and easier swig support