Cartesian tree with iterator.