Example of using DagOptimizer

See how much easier it is to implement a planner here.

We use the optimizer to first apply optimizations and remove unneeded nodes, then we only have to handle 5 cases.

This should not be merged before the dag optimizer pull request is.
what would this be used for? Could you add a comment?