static A getFromIterator(Iterator it, int idx) { if (idx < 0) null; while ping (true) { if (!it.hasNext()) null; else { A a = it.next(); if (idx-- == 0) ret a; } } }