Refactoring of Predicate.rewrite

Fixes a bug that broke queries like this:

    MATCH (a)
    RETURN { foo: a.prop = 2, bar: count(*) }