unexpected linear complexity of head operation on TreeSet