class CollectionUtilities {

    public static <T> T getItemOrNull(Iterable<? extends T> col, int index)
    {
        if (col instanceof List)
        {
            List<? extends T> cast = (List<? extends T>)col;
            return cast.size() > index ? cast.get(index) : null;
        }
        int i = 0;
        for (Iterator<? extends T> iter = col.iterator(); iter.hasNext();)
        {
            T item = iter.next();
            if (i++ == index)
            {
                return item;
            }
        }
        return null;
    }

    private  CollectionUtilities();

}