Index: trunk/quest-core-tasktrees/src/main/java/de/ugoe/cs/quest/tasktrees/temporalrelation/DefaultIterationDetectionRule.java
===================================================================
--- trunk/quest-core-tasktrees/src/main/java/de/ugoe/cs/quest/tasktrees/temporalrelation/DefaultIterationDetectionRule.java	(revision 815)
+++ trunk/quest-core-tasktrees/src/main/java/de/ugoe/cs/quest/tasktrees/temporalrelation/DefaultIterationDetectionRule.java	(revision 818)
@@ -391,32 +391,53 @@
     {
         ITaskTreeNode mergeResult = null;
-        NodeEquality nodeEquality = nodeEqualityRuleManager.applyRules(node1, node2);
-        
-        if (nodeEquality.isAtLeast(NodeEquality.LEXICALLY_EQUAL)) {
+        
+        if ((node1 instanceof ISequence) && (node2 instanceof ISequence)) {
+            mergeResult = mergeEqualSequences
+                ((ISequence) node1, (ISequence) node2, treeBuilder, nodeFactory);
+        }
+        else if ((node1 instanceof ISelection) && (node2 instanceof ISelection)) {
+            mergeResult = mergeEqualSelections
+                ((ISelection) node1, (ISelection) node2, treeBuilder, nodeFactory);
+        }
+        else if ((node1 instanceof IIteration) && (node2 instanceof IIteration)) {
+            mergeResult = mergeEqualIterations
+                ((IIteration) node1, (IIteration) node2, treeBuilder, nodeFactory);
+        }
+        else if (node1 instanceof ISelection) {
+            treeBuilder.addChild((ISelection) node1, node2);
             mergeResult = node1;
         }
+        else if (node2 instanceof ISelection) {
+            treeBuilder.addChild((ISelection) node2, node1);
+            mergeResult = node2;
+        }
+        else if (node1 instanceof IIteration) {
+            mergeResult = mergeEqualTasks
+                (((IIteration) node1).getChildren().get(0), node2, treeBuilder, nodeFactory);
+            
+            if (mergeResult != null) {
+                IIteration iteration = nodeFactory.createNewIteration();
+                treeBuilder.setChild(iteration, mergeResult);
+                mergeResult = iteration;
+            }
+        }
+        else if (node2 instanceof IIteration) {
+            mergeResult = mergeEqualTasks
+                (((IIteration) node2).getChildren().get(0), node1, treeBuilder, nodeFactory);
+            
+            if (mergeResult != null) {
+                IIteration iteration = nodeFactory.createNewIteration();
+                treeBuilder.setChild(iteration, mergeResult);
+                mergeResult = iteration;
+            }
+        }
         else {
-            if ((node1 instanceof ISequence) && (node2 instanceof ISequence)) {
-                mergeResult = mergeEqualSequences
-                    ((ISequence) node1, (ISequence) node2, treeBuilder, nodeFactory);
-            }
-            else if ((node1 instanceof ISelection) && (node2 instanceof ISelection)) {
-                mergeResult = mergeEqualSelections
-                    ((ISelection) node1, (ISelection) node2, treeBuilder, nodeFactory);
-            }
-            else if ((node1 instanceof IIteration) && (node2 instanceof IIteration)) {
-                mergeResult = mergeEqualIterations
-                    ((IIteration) node1, (IIteration) node2, treeBuilder, nodeFactory);
-            }
-            else if (node1 instanceof ISelection) {
-                treeBuilder.addChild((ISelection) node1, node2);
+            NodeEquality nodeEquality = nodeEqualityRuleManager.applyRules(node1, node2);
+            
+            if (nodeEquality.isAtLeast(NodeEquality.LEXICALLY_EQUAL)) {
                 mergeResult = node1;
             }
-            else if (node2 instanceof ISelection) {
-                treeBuilder.addChild((ISelection) node2, node1);
-                mergeResult = node2;
-            }
-        }
-        
+        }
+
         if (mergeResult == null) {
             mergeResult = nodeFactory.createNewSelection();
@@ -528,5 +549,5 @@
     {
         ITaskTreeNode mergedChild = mergeEqualTasks
-            (iteration1.getChildren().get(0), iteration1.getChildren().get(0),
+            (iteration1.getChildren().get(0), iteration2.getChildren().get(0),
              treeBuilder, nodeFactory);
         
