__contains__ methods, to reduce the amount of iteration and incipient json encoding
more __contains__ and some refactoring