Fixes #1012

It was not possible to access an attribute of a key in a PredicateBuilder.
Merged PR #1013. Some refactorings.