Object first = queue.removeFirst();
if (first instanceof FileCollection) {
result.add(first);
} else if (first instanceof Closure) {
Closure closure = (Closure) first;
Object closureResult = closure.call();
if (closureResult != null) {
queue.addFirst(closureResult);
}
} else if (first instanceof Collection) {
Collection<?> collection = (Collection<?>) first;