Introduce exhaustive planner for Cypher

This also includes a commit that is in #3670