def get_element_at(element_idx, it):
    """ :return it[element_idx] also for non-indexable iterators. NOTE: exhausts iterator! """
    try:
        return it[element_idx]
    except TypeError:
        pass
    for i, el in enumerate(it):
        if i == element_idx:
            return el
    raise IndexError('Iterator does not have {} elements'.format(element_idx))
