A naive query tree optimizer.