Slightly complicated by the fact that the `lookup` function doesn't yet exist for `Data.Tree.AVL`. Should also increase the performance of the solver.