public static <T> T headOrNull(Iterable<T> ts) { Iterator<T> it = ts.iterator(); return it.hasNext() ? it.next() : null; }
Other options: