You could code this:
Iterator<NodeInstance> iterator = nodes.iterator();
do {
processTasks = iterator.next().getNodeName();
System.out.println(processTasks + " - " + count);
count = count + 1;
} while (count < nodes.size());
iterator() method will give you a new iterator instance when you invoke it every time.So you get the first Nodeinstance every time.