Index: branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionTracing.cs
===================================================================
--- branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionTracing.cs	(revision 10797)
+++ branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionTracing.cs	(revision 10827)
@@ -10,5 +10,5 @@
 using IGraphNode = HeuristicLab.EvolutionTracking.IGenealogyGraphNode<HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ISymbolicExpressionTree>;
 
-namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
   public static class SymbolicDataAnalysisExpressionTracing {
     public static IGenealogyGraph<IFragment<ISymbolicExpressionTreeNode>> TraceSubtree(IGenealogyGraphNode<ISymbolicExpressionTree> graphNode, int subtreeIndex) {
@@ -40,54 +40,82 @@
           break;
         }
-
+        var parents = node.Parents.ToList();
         if (node.IsElite) {
-          node = node.Parents.First();
+          // skip elite, go up the graph to original individual
+          node = parents[0];
           continue;
-        } // skip elite, go up the graph to original individual
-
+        }
+        var fragment = (IFragment<ISymbolicExpressionTreeNode>)node.InArcs.Last().Data;
+        if (fragment == null) {
+          // the fragment can be null when crossover or mutation did not actually make any change => then we skip
+          node = parents[0];
+          continue;
+        }
+        var fragmentLength = fragment.Root.GetLength();
         var tree = node.Content;
         var subtree = tree.NodeAt(index);
         var subtreeLength = subtree.GetLength();
 
-        var fragment = (IFragment<ISymbolicExpressionTreeNode>)node.InArcs.Last().Data;
-        if (fragment == null) break;
-        var fragmentLength = fragment.Root.GetLength();
+        if (parents.Count == 1) {
+          // we are tracing a mutation operation
+          var fragmentNode = new FragmentNode {
+            Content = new Fragment<ISymbolicExpressionTreeNode> { Root = subtree },
+            Rank = node.Rank
+          };
+          if (parent != null) {
+            var arc = new GenealogyGraphArc { Source = parent, Target = fragmentNode };
+            parent.AddForwardArc(arc);
+          }
+          yield return fragmentNode;
+          var up = Trace(parents[0], fragment.Index1, fragmentNode);
+          foreach (var v in up) { yield return v; }
+          break;
+        }
 
-        if (fragment.Index1 == index) {
-          node = node.Parents.Last(); // take second parent which contains the fragment
-          index = fragment.Index2;
-        } else if (fragment.Index1 < index) {
-          if (fragment.Index1 + fragmentLength > index) {
-            node = node.Parents.Last(); // fragment contains subtree, take second parent
-            index += fragment.Index2 - fragment.Index1; // the subtree has the same index relative to the fragment
-          } else {
-            // fragment distinct from subtree
-            node = node.Parents.First(); // take first parent which contains the subtree
-            index += node.Content.NodeAt(fragment.Index1).GetLength() - fragmentLength; // subtreeIndex must be adjusted according to swapped fragments sizes
+        if (parents.Count == 2) {
+          // we are tracing a crossover operation
+          if (fragment.Index1 == index) {
+            node = parents[1]; // take second parent which contains the fragment
+            index = fragment.Index2;
+            continue;
           }
-        } else if (fragment.Index1 > index) {
-          if (fragment.Index1 < index + subtreeLength) {
-            // subtree contains fragment => bifurcation point in the fragment graph
-            var fragmentNode = new FragmentNode {
-              Content = new Fragment<ISymbolicExpressionTreeNode> { Root = subtree },
-              Rank = node.Rank
-            };
-            if (parent != null) {
-              var arc = new GenealogyGraphArc { Source = parent, Target = fragmentNode };
-              parent.AddForwardArc(arc);
+
+          if (fragment.Index1 < index) {
+            if (fragment.Index1 + fragmentLength > index) {
+              node = parents[1]; // fragment contains subtree, take second parent
+              index += fragment.Index2 - fragment.Index1; // the subtree has the same index relative to the fragment
+            } else {
+              // fragment distinct from subtree
+              node = parents[0]; // take first parent which contains the subtree
+              index += node.Content.NodeAt(fragment.Index1).GetLength() - fragmentLength; // subtreeIndex must be adjusted according to swapped fragments sizes
             }
-            fragmentNode.Content.Index1 = fragment.Index1 - index;
-            yield return fragmentNode;
+            continue;
+          }
 
-            var left = Trace(node.Parents.First(), index, fragmentNode); // trace subtree
+          if (fragment.Index1 > index) {
+            if (fragment.Index1 < index + subtreeLength) {
+              // subtree contains fragment => bifurcation point in the fragment graph
+              var fragmentNode = new FragmentNode {
+                Content = new Fragment<ISymbolicExpressionTreeNode> { Root = subtree },
+                Rank = node.Rank
+              };
+              if (parent != null) {
+                var arc = new GenealogyGraphArc { Source = parent, Target = fragmentNode };
+                parent.AddForwardArc(arc);
+              }
+              fragmentNode.Content.Index1 = fragment.Index1 - index;
+              yield return fragmentNode;
 
-            if (node.Parents.Last().Content.NodeAt(fragment.Index2).GetLength() != fragmentLength) {
-              throw new Exception("Fragment lengths should match!");
+              if (parents[1].Content.NodeAt(fragment.Index2).GetLength() != fragmentLength) {
+                throw new Exception("Fragment lengths should match!");
+              }
+              // the two paths below ("left" and "right") correspond to the subtree and the fragment, respectively
+              var left = Trace(parents[0], index, fragmentNode); // trace subtree
+              var right = Trace(parents[1], fragment.Index2, fragmentNode); // trace fragment
+              foreach (var v in left.Concat(right)) { yield return v; }
+              break;
+            } else {
+              node = parents[0]; // fragment distinct from subtree: update node, index remains unchanged
             }
-            var right = Trace(node.Parents.Last(), fragment.Index2, fragmentNode); // trace fragment
-            foreach (var v in left.Concat(right)) { yield return v; }
-            break;
-          } else {
-            node = node.Parents.First(); // fragment distinct from subtree: update node, index remains unchanged
           }
         }
@@ -101,5 +129,4 @@
     }
     #region some helper methods for shortening the tracing code
-
     private static void AddChild(this IGenealogyGraphNode parent, IGenealogyGraphNode child) {
       parent.AddForwardArc(child);
