NodeSequence seq = NodeSequence.append(allNodes(), allNodes());
// The sequence should not have two duplicates of every node ...
Set<NodeKey> keys = new HashSet<NodeKey>();
try {
// Iterate over the batches ...
Batch batch = null;
boolean shouldAdd = true;
while ((batch = seq.nextBatch()) != null) {
while (batch.hasNext()) {
batch.nextRow();
CachedNode node = batch.getNode();
NodeKey key = node != null ? node.getKey() : null;
if (keys.contains(key) && shouldAdd) shouldAdd = false;
if (shouldAdd) {
boolean added = keys.add(key);
print("Adding " + key);