added PlanReducer class which will do all the dirty work of simplifying the query plan so the query can be reconstructed