Index: trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/CondenseSimilarTasksRuleTest.java
===================================================================
--- trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/CondenseSimilarTasksRuleTest.java	(revision 1846)
+++ trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/CondenseSimilarTasksRuleTest.java	(revision 1954)
@@ -666,5 +666,79 @@
         String output =
             "UserSession {" +
-            "  Selection sel1 {" +
+            "  Sequence sequence5 {" +
+            "    Iteration itSequence6 {" +
+            "      Sequence sequence6 {" +
+            "        Event action1 {}" +
+            "        Selection 1 {" +
+            "          Event action2 {}" +
+            "        }" +
+            "      }" +
+            "      Sequence sequence6 {" +
+            "        Event action1 {}" +
+            "        Selection 1 {" +
+            "          Event action2 {}" +
+            "        }" +
+            "      }" +
+            "    }" +
+            "    Event action3 {}" +
+            "  }" +
+            "  Sequence sequence5 {" +
+            "    Iteration itSequence6 {" +
+            "      Sequence sequence6 {" +
+            "        Event action1 {}" +
+            "        Selection 1 {" +
+            "          Event action4 {}" +
+            "        }" +
+            "      }" +
+            "    }" +
+            "    Event action3 {}" +
+            "  }" +
+            "}";
+
+        applySessionScopeRule(CondenseSimilarTasksRule.class, input, output);
+    }
+
+    /**
+     *
+     */
+    @Test
+    public void test_IterationPreservation_03() throws Exception {
+        String input =
+            "UserSession {" +
+            "  Sequence sequence1 {" +
+            "    Iteration itSequence2 {" +
+            "      Sequence sequence2 {" +
+            "        Event action1 {}" +
+            "        Event action2 {}" +
+            "      }" +
+            "      Sequence sequence2 {" +
+            "        Event action1 {}" +
+            "        Event action2 {}" +
+            "      }" +
+            "    }" +
+            "    Event action3 {}" +
+            "  }" +
+            "  Sequence sequence3 {" +
+            "    Event action1 {}" +
+            "    Iteration itSequence4 {" +
+            "      Sequence sequence4 {" +
+            "        Event action4 {}" +
+            "        Event action3 {}" +
+            "      }" +
+            "      Sequence sequence4 {" +
+            "        Event action4 {}" +
+            "        Event action3 {}" +
+            "      }" +
+            "      Sequence sequence4 {" +
+            "        Event action4 {}" +
+            "        Event action3 {}" +
+            "      }" +
+            "    }" +
+            "  }" +
+            "}";
+
+        String output =
+            "UserSession {" +
+            "  Selection selection1 {" +
             "    Sequence sequence1 {" +
             "      Iteration itSequence2 {" +
@@ -681,5 +755,5 @@
             "    }" +
             "  }" +
-            "  Selection sel1 {" +
+            "  Selection selection1 {" +
             "    Sequence sequence3 {" +
             "      Event action1 {}" +
@@ -689,4 +763,12 @@
             "          Event action3 {}" +
             "        }" +
+            "        Sequence sequence4 {" +
+            "          Event action4 {}" +
+            "          Event action3 {}" +
+            "        }" +
+            "        Sequence sequence4 {" +
+            "          Event action4 {}" +
+            "          Event action3 {}" +
+            "        }" +
             "      }" +
             "    }" +
@@ -701,5 +783,5 @@
      */
     @Test
-    public void test_IterationPreservation_03() throws Exception {
+    public void test_IterationPreservation_04() throws Exception {
         String input =
             "UserSession {" +
@@ -734,6 +816,86 @@
         String output =
             "UserSession {" +
+            "  Iteration itSequence5 {" +
+            "    Sequence sequence5 {" +
+            "      Iteration itSequence6 {" +
+            "        Sequence sequence6 {" +
+            "          Event action1 {}" +
+            "          Selection 1 {" +
+            "            Event action2 {}" +
+            "          }" +
+            "        }" +
+            "        Sequence sequence6 {" +
+            "          Event action1 {}" +
+            "          Selection 1 {" +
+            "            Event action2 {}" +
+            "          }" +
+            "        }" +
+            "      }" +
+            "      Event action3 {}" +
+            "    }" +
+            "    Sequence sequence5 {" +
+            "      Iteration itSequence6 {" +
+            "        Sequence sequence6 {" +
+            "          Event action1 {}" +
+            "          Selection 1 {" +
+            "            Event action4 {}" +
+            "          }" +
+            "        }" +
+            "      }" +
+            "      Event action3 {}" +
+            "    }" +
+            "  }" +
+            "}";
+
+        applySessionScopeRule(CondenseSimilarTasksRule.class, input, output);
+    }
+
+    /**
+     *
+     */
+    @Test
+    public void test_IterationPreservation_05() throws Exception {
+        String input =
+            "UserSession {" +
+            "  Iteration itSequence1 {" +
+            "    Sequence sequence1 {" +
+            "      Iteration itSequence2 {" +
+            "        Sequence sequence2 {" +
+            "          Event action1 {}" +
+            "          Event action2 {}" +
+            "        }" +
+            "        Sequence sequence2 {" +
+            "          Event action1 {}" +
+            "          Event action2 {}" +
+            "        }" +
+            "      }" +
+            "      Event action3 {}" +
+            "    }" +
+            "  }" +
+            "  Iteration itSequence3 {" +
+            "    Sequence sequence3 {" +
+            "      Event action1 {}" +
+            "      Iteration itSequence4 {" +
+            "        Sequence sequence4 {" +
+            "          Event action4 {}" +
+            "          Event action3 {}" +
+            "        }" +
+            "        Sequence sequence4 {" +
+            "          Event action4 {}" +
+            "          Event action3 {}" +
+            "        }" +
+            "        Sequence sequence4 {" +
+            "          Event action4 {}" +
+            "          Event action3 {}" +
+            "        }" +
+            "      }" +
+            "    }" +
+            "  }" +
+            "}";
+
+        String output =
+            "UserSession {" +
             "  Iteration itSelection1 {" +
-            "    Selection sel1 {" +
+            "    Selection selection1 {" +
             "      Sequence sequence1 {" +
             "        Iteration itSequence2 {" +
@@ -750,5 +912,5 @@
             "      }" +
             "    }" +
-            "    Selection sel1 {" +
+            "    Selection selection1 {" +
             "      Sequence sequence3 {" +
             "        Event action1 {}" +
@@ -758,4 +920,12 @@
             "            Event action3 {}" +
             "          }" +
+            "          Sequence sequence4 {" +
+            "            Event action4 {}" +
+            "            Event action3 {}" +
+            "          }" +
+            "          Sequence sequence4 {" +
+            "            Event action4 {}" +
+            "            Event action3 {}" +
+            "          }" +
             "        }" +
             "      }" +
@@ -771,5 +941,5 @@
      */
     @Test
-    public void test_IterationPreservation_04() throws Exception {
+    public void test_IterationPreservation_06() throws Exception {
         String input =
             "UserSession {" +
@@ -810,37 +980,235 @@
         String output =
             "UserSession {" +
-            "  Selection sel1 {" +
-            "    Sequence sequence1 {" +
-            "      Iteration itSequence2 {" +
-            "        Sequence sequence2 {" +
-            "          Event action1 {}" +
-            "          Iteration itSequence3 {" +
-            "            Sequence sequence3 {" +
-            "              Event action2 {}" +
+            "  Sequence sequence7 {" +
+            "    Event action1 {}" +
+            "    Iteration itSequence8 {" +
+            "      Sequence sequence8 {" +
+            "        Event action2 {}" +
+            "        Selection selection1 {" +
+            "          Event action3 {}" +
+            "        }" +
+            "      }" +
+            "      Sequence sequence8 {" +
+            "        Event action2 {}" +
+            "        Selection selection1 {" +
+            "          Event action3 {}" +
+            "        }" +
+            "      }" +
+            "    }" +
+            "    Event action4 {}" +
+            "  }" +
+            "  Sequence sequence7 {" +
+            "    Event action1 {}" +
+            "    Iteration itSequence8 {" +
+            "      Sequence sequence8 {" +
+            "        Event action2 {}" +
+            "        Selection selection1 {" +
+            "          Event action5 {}" +
+            "        }" +
+            "      }" +
+            "    }" +
+            "    Event action4 {}" +
+            "  }" +
+            "}";
+
+        applySessionScopeRule(CondenseSimilarTasksRule.class, input, output);
+    }
+
+    /**
+     *
+     */
+    @Test
+    public void test_IterationPreservation_07() throws Exception {
+        String input =
+            "UserSession {" +
+            "  Sequence sequence1 {" +
+            "    Iteration itSequence2 {" +
+            "      Sequence sequence2 {" +
+            "        Event action1 {}" +
+            "        Iteration itSequence3 {" +
+            "          Sequence sequence3 {" +
+            "            Event action2 {}" +
+            "            Event action3 {}" +
+            "          }" +
+            "          Sequence sequence3 {" +
+            "            Event action2 {}" +
+            "            Event action3 {}" +
+            "          }" +
+            "        }" +
+            "      }" +
+            "    }" +
+            "    Event action4 {}" +
+            "  }" +
+            "  Sequence sequence4 {" +
+            "    Event action1 {}" +
+            "    Iteration itSequence5 {" +
+            "      Sequence sequence5 {" +
+            "        Iteration itSequence6 {" +
+            "          Sequence sequence6 {" +
+            "            Event action2 {}" +
+            "            Event action5 {}" +
+            "          }" +
+            "          Sequence sequence6 {" +
+            "            Event action2 {}" +
+            "            Event action5 {}" +
+            "          }" +
+            "          Sequence sequence6 {" +
+            "            Event action2 {}" +
+            "            Event action5 {}" +
+            "          }" +
+            "        }" +
+            "        Event action4 {}" +
+            "      }" +
+            "    }" +
+            "  }" +
+            "}";
+
+        String output =
+            "UserSession {" +
+            "  Sequence sequence7 {" +
+            "    Event action1 {}" +
+            "    Iteration itSequence8 {" +
+            "      Sequence sequence8 {" +
+            "        Event action2 {}" +
+            "        Selection selection1 {" +
+            "          Event action3 {}" +
+            "        }" +
+            "      }" +
+            "      Sequence sequence8 {" +
+            "        Event action2 {}" +
+            "        Selection selection1 {" +
+            "          Event action3 {}" +
+            "        }" +
+            "      }" +
+            "    }" +
+            "    Event action4 {}" +
+            "  }" +
+            "  Sequence sequence7 {" +
+            "    Event action1 {}" +
+            "    Iteration itSequence8 {" +
+            "      Sequence sequence8 {" +
+            "        Event action2 {}" +
+            "        Selection selection1 {" +
+            "          Event action5 {}" +
+            "        }" +
+            "      }" +
+            "      Sequence sequence8 {" +
+            "        Event action2 {}" +
+            "        Selection selection1 {" +
+            "          Event action5 {}" +
+            "        }" +
+            "      }" +
+            "      Sequence sequence8 {" +
+            "        Event action2 {}" +
+            "        Selection selection1 {" +
+            "          Event action5 {}" +
+            "        }" +
+            "      }" +
+            "    }" +
+            "    Event action4 {}" +
+            "  }" +
+            "}";
+
+        applySessionScopeRule(CondenseSimilarTasksRule.class, input, output);
+    }
+
+    /**
+     *
+     */
+    @Test
+    public void test_IterationPreservation_08() throws Exception {
+        String input =
+            "UserSession {" +
+            "  Sequence sequence1 {" +
+            "    Iteration itSequence2 {" +
+            "      Sequence sequence2 {" +
+            "        Event action1 {}" +
+            "        Iteration itSequence3 {" +
+            "          Sequence sequence3 {" +
+            "            Event action2 {}" +
+            "            Event action3 {}" +
+            "          }" +
+            "          Sequence sequence3 {" +
+            "            Event action2 {}" +
+            "            Event action3 {}" +
+            "          }" +
+            "        }" +
+            "      }" +
+            "    }" +
+            "    Event action4 {}" +
+            "  }" +
+            "  Sequence sequence4 {" +
+            "    Event action1 {}" +
+            "    Iteration itSequence5 {" +
+            "      Sequence sequence5 {" +
+            "        Iteration itSequence6 {" +
+            "          Sequence sequence6 {" +
+            "            Event action2 {}" +
+            "            Event action5 {}" +
+            "          }" +
+            "        }" +
+            "        Event action4 {}" +
+            "      }" +
+            "      Sequence sequence5 {" +
+            "        Iteration itSequence6 {" +
+            "          Sequence sequence6 {" +
+            "            Event action2 {}" +
+            "            Event action5 {}" +
+            "          }" +
+            "        }" +
+            "        Event action4 {}" +
+            "      }" +
+            "    }" +
+            "  }" +
+            "}";
+
+        String output =
+            "UserSession {" +
+            "  Sequence sequence7 {" +
+            "    Event action1 {}" +
+            "    Iteration itSequence8 {" +
+            "      Sequence sequence8 {" +
+            "        Iteration itSequence9 {" +
+            "          Sequence sequence9 {" +
+            "            Event action2 {}" +
+            "            Selection selection1 {" +
             "              Event action3 {}" +
             "            }" +
-            "            Sequence sequence3 {" +
-            "              Event action2 {}" +
+            "          }" +
+            "          Sequence sequence9 {" +
+            "            Event action2 {}" +
+            "            Selection selection1 {" +
             "              Event action3 {}" +
             "            }" +
             "          }" +
             "        }" +
-            "      }" +
-            "      Event action4 {}" +
-            "    }" +
-            "  }" +
-            "  Selection sel1 {" +
-            "    Sequence sequence4 {" +
-            "      Event action1 {}" +
-            "      Iteration itSequence5 {" +
-            "        Sequence sequence5 {" +
-            "          Iteration itSequence6 {" +
-            "            Sequence sequence6 {" +
-            "              Event action2 {}" +
-            "              Event action5 {}" +
-            "            }" +
-            "          }" +
-            "          Event action4 {}" +
-            "        }" +
+            "        Event action4 {}" +
+            "      }" +
+            "    }" +
+            "  }" +
+            "  Sequence sequence7 {" +
+            "    Event action1 {}" +
+            "    Iteration itSequence8 {" +
+            "      Sequence sequence8 {" +
+            "        Iteration itSequence9 {" +
+            "          Sequence sequence9 {" +
+            "            Event action2 {}" +
+            "            Selection selection1 {" +
+            "              Event action3 {}" +
+            "            }" +
+            "          }" +
+            "        }" +
+            "        Event action4 {}" +
+            "      }" +
+            "      Sequence sequence8 {" +
+            "        Iteration itSequence9 {" +
+            "          Sequence sequence9 {" +
+            "            Event action2 {}" +
+            "            Selection selection1 {" +
+            "              Event action3 {}" +
+            "            }" +
+            "          }" +
+            "        }" +
+            "        Event action4 {}" +
             "      }" +
             "    }" +
@@ -855,5 +1223,5 @@
      */
     @Test
-    public void test_IterationPreservation_05() throws Exception {
+    public void test_IterationPreservation_09() throws Exception {
         String input =
             "UserSession {" +
@@ -919,35 +1287,19 @@
             "    Event noiseAction1 {}" +
             "    Iteration itSelection1 {" +
-            "      Selection sel1 {" +
-            "        Sequence sequence2 {" +
-            "          Iteration itSequence3 {" +
-            "            Sequence sequence3 {" +
-            "              Event action1 {}" +
-            "              Iteration itSequence4 {" +
-            "                Sequence sequence4 {" +
-            "                  Event action2 {}" +
-            "                  Event action3 {}" +
-            "                }" +
-            "              }" +
-            "            }" +
-            "          }" +
-            "          Event action4 {}" +
-            "        }" +
-            "      }" +
-            "      Selection sel1 {" +
-            "        Sequence sequence2 {" +
-            "          Iteration itSequence3 {" +
-            "            Sequence sequence3 {" +
-            "              Event action1 {}" +
-            "              Iteration itSequence4 {" +
-            "                Sequence sequence4 {" +
-            "                  Event action2 {}" +
-            "                  Event action3 {}" +
-            "                }" +
-            "              }" +
-            "            }" +
-            "          }" +
-            "          Event action4 {}" +
-            "        }" +
+            "      Sequence sequence10 {" +
+            "        Event action1 {}" +
+            "        Selection selection1 {" +
+            "          Event action2 {}" +
+            "        }" +
+            "        Event action3 {}" +
+            "        Event action4 {}" +
+            "      }" +
+            "      Sequence sequence10 {" +
+            "        Event action1 {}" +
+            "        Selection selection1 {" +
+            "          Event action2 {}" +
+            "        }" +
+            "        Event action3 {}" +
+            "        Event action4 {}" +
             "      }" +
             "    }" +
@@ -957,19 +1309,11 @@
             "    Event noiseAction1 {}" +
             "    Iteration itSelection1 {" +
-            "      Selection sel1 {" +
-            "        Sequence sequence6 {" +
-            "          Event action1 {}" +
-            "          Iteration itSequence7 {" +
-            "            Sequence sequence7 {" +
-            "              Iteration itSequence8 {" +
-            "                Sequence sequence8 {" +
-            "                  Event action5 {}" +
-            "                  Event action3 {}" +
-            "                }" +
-            "              }" +
-            "              Event action4 {}" +
-            "            }" +
-            "          }" +
-            "        }" +
+            "      Sequence sequence10 {" +
+            "        Event action1 {}" +
+            "        Selection selection1 {" +
+            "          Event action5 {}" +
+            "        }" +
+            "        Event action3 {}" +
+            "        Event action4 {}" +
             "      }" +
             "    }" +
@@ -985,5 +1329,5 @@
      */
     @Test
-    public void test_IterationPreservation_06() throws Exception {
+    public void test_IterationPreservation_10() throws Exception {
         String input =
             "UserSession {" +
