} catch (RepositoryException re) {
log.warn("inconsistent hierarchy state", re);
}
// create an iterator over the collected descendants
// in decreasing depth order
IteratorChain resultIter = new IteratorChain();
for (int i = la.length - 1; i >= 0; i--) {
List list = la[i];
if (list != null) {
resultIter.addIterator(list.iterator());
}
}
/**
* if the resulting iterator chain is empty return
* EMPTY_LIST.iterator() instead because older versions
* of IteratorChain (pre Commons Collections 3.1)
* would throw UnsupportedOperationException in this
* situation
*/
if (resultIter.getIterators().isEmpty()) {
List<ItemState> empty = Collections.emptyList();
return empty.iterator();
}
return resultIter;
}