for (int i = 0; i < downstreamElements.size(); i++) {
SelectableQueue<Object> downstreamQueue = downstreamQueues.get(i);
FlowElement downstreamElement = downstreamElements.get(i);
if (downstreamQueue == null) {
// Close directly.
downstreamElement.closeUpstream();
} else if (downstreamQueue.size() == 0) {
// Queue's dry, close it down.
closeQueue(downstreamQueue, downstreamElement);
} else {
// Watch this queue for completion.