use TreeMap natural order to implement z order