More work on the new planner for Cypher

A little refactoring, and also added the inner loop that searches for expansion and joins