Index: trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/LayoutEngines/BoxesLayoutEngine.cs
===================================================================
--- trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/LayoutEngines/BoxesLayoutEngine.cs	(revision 10520)
+++ trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/LayoutEngines/BoxesLayoutEngine.cs	(revision 10520)
@@ -0,0 +1,137 @@
+﻿
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+
+namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
+  public class BoxesLayoutEngine<T> : ILayoutEngine<T> where T : class {
+    private readonly Dictionary<T, VisualTreeNode<T>> nodeMap;
+
+    public int NodeWidth { get; set; }
+    public int NodeHeight { get; set; }
+    public int HorizontalSpacing { get; set; }
+    public int VerticalSpacing { get; set; }
+    private VisualTreeNode<T> layoutRoot;
+
+    public int Width { get; private set; }
+    public int Height { get; private set; }
+
+    public Func<T, IEnumerable<T>> GetChildren { get; set; }
+    public Func<T, int> GetLength { get; set; }
+    public Func<T, int> GetDepth { get; set; }
+
+    public BoxesLayoutEngine() {
+      nodeMap = new Dictionary<T, VisualTreeNode<T>>();
+    }
+
+    public void CalculateLayout() {
+      throw new Exception("The BoxesLayoutEngine does not support arbitrary bounds. Please use method CalculateLayout(Width, Height)");
+    }
+
+    public void CalculateLayout(float width, float height) {
+      Width = (int)Math.Round(width);
+      Height = (int)Math.Round(height);
+      Reset();
+      RecursiveLayout(layoutRoot, 0, 0, Width, Height / GetDepth(layoutRoot.Content));
+    }
+
+    public void Initialize(T root, Func<T, IEnumerable<T>> getChildren, Func<T, int> getLength, Func<T, int> getDepth) {
+      if (getChildren == null || getLength == null || getDepth == null)
+        throw new ArgumentNullException("The BoxesLayoutEngine requires all of the lambdas: (getChildren, getLength and getDepth) to be defined.");
+      GetChildren = getChildren;
+      GetLength = getLength;
+      GetDepth = getDepth;
+      Clear();
+      Expand(root); // produce the nodeMap
+      layoutRoot = nodeMap[root];
+    }
+
+    private void Expand(T root) {
+      var node = new VisualTreeNode<T>(root) {
+        PreferredWidth = NodeWidth,
+        PreferredHeight = NodeHeight
+      };
+      nodeMap.Add(root, node);
+      var children = GetChildren(root).ToList();
+      if (children.Any()) {
+        foreach (var child in children) {
+          Expand(child);
+        }
+      }
+    }
+
+    public void Center(float width, float height) {
+      // does nothing because the BoxesLayout centers the tree by default
+    }
+
+    public void Clear() {
+      nodeMap.Clear();
+      layoutRoot = null;
+    }
+
+    public void Reset() {
+      foreach (var node in nodeMap.Values) {
+        node.X = 0;
+        node.Y = 0;
+      }
+    }
+
+    public Dictionary<T, PointF> GetCoordinates() {
+      return nodeMap.ToDictionary(x => x.Key, x => new PointF(x.Value.X, x.Value.Y));
+    }
+
+    public void FitToBounds(float width, float height) {
+      // does nothing because the BoxesLayout is by default stretched on the whole drawing area
+    }
+
+    private void RecursiveLayout(VisualTreeNode<T> visualTreeNode, int x, int y, int width, int height) {
+      float center_x = x + width / 2;
+      float center_y = y + height / 2;
+      int actualWidth = width - VerticalSpacing;
+      int actualHeight = height - VerticalSpacing;
+
+      //calculate size of node
+      if (actualWidth >= visualTreeNode.PreferredWidth && actualHeight >= visualTreeNode.PreferredHeight) {
+        visualTreeNode.Width = visualTreeNode.PreferredWidth;
+        visualTreeNode.Height = visualTreeNode.PreferredHeight;
+        visualTreeNode.X = (int)center_x - visualTreeNode.Width / 2;
+        visualTreeNode.Y = (int)center_y - visualTreeNode.Height / 2;
+      }
+        //width too small to draw in desired sized
+      else if (actualWidth < visualTreeNode.PreferredWidth && actualHeight >= visualTreeNode.PreferredHeight) {
+        visualTreeNode.Width = actualWidth;
+        visualTreeNode.Height = visualTreeNode.PreferredHeight;
+        visualTreeNode.X = x;
+        visualTreeNode.Y = (int)center_y - visualTreeNode.Height / 2;
+      }
+        //height too small to draw in desired sized
+      else if (actualWidth >= visualTreeNode.PreferredWidth && actualHeight < visualTreeNode.PreferredHeight) {
+        visualTreeNode.Width = visualTreeNode.PreferredWidth;
+        visualTreeNode.Height = actualHeight;
+        visualTreeNode.X = (int)center_x - visualTreeNode.Width / 2;
+        visualTreeNode.Y = y;
+      }
+        //width and height too small to draw in desired size
+      else {
+        visualTreeNode.Width = actualWidth;
+        visualTreeNode.Height = actualHeight;
+        visualTreeNode.X = x;
+        visualTreeNode.Y = y;
+      }
+      //calculate areas for the subtrees according to their tree size and call drawFunctionTree
+      var node = visualTreeNode.Content;
+      var children = GetChildren(node).ToList();
+      int[] xBoundaries = new int[children.Count + 1];
+      xBoundaries[0] = x;
+      for (int i = 0; i < children.Count; i++) {
+        xBoundaries[i + 1] = (int)(xBoundaries[i] + (width * (double)GetLength(children[i])) / (GetLength(node) - 1));
+        RecursiveLayout(nodeMap[children[i]], xBoundaries[i], y + height, xBoundaries[i + 1] - xBoundaries[i], height);
+      }
+    }
+
+    public IEnumerable<VisualTreeNode<T>> GetVisualNodes() {
+      return nodeMap.Values;
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/LayoutEngines/ILayoutEngine.cs
===================================================================
--- trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/LayoutEngines/ILayoutEngine.cs	(revision 10520)
+++ trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/LayoutEngines/ILayoutEngine.cs	(revision 10520)
@@ -0,0 +1,27 @@
+﻿
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+
+namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
+  interface ILayoutEngine<T> where T : class {
+    int NodeWidth { get; set; }
+    int NodeHeight { get; set; }
+    int HorizontalSpacing { get; set; }
+    int VerticalSpacing { get; set; }
+
+    void CalculateLayout();
+    void CalculateLayout(float width, float height);
+    void Initialize(T root, Func<T, IEnumerable<T>> getChildren, Func<T, int> getLength = null, Func<T, int> getDepth = null);
+    void Clear();
+    void Reset();
+
+    // function members necessary to navigate the tree structure
+    Func<T, IEnumerable<T>> GetChildren { get; set; }
+    Func<T, int> GetLength { get; set; }
+    Func<T, int> GetDepth { get; set; }
+
+    IEnumerable<VisualTreeNode<T>> GetVisualNodes();
+    Dictionary<T, PointF> GetCoordinates();
+  }
+}
Index: trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/LayoutEngines/LayoutNode.cs
===================================================================
--- trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs	(revision 10496)
+++ trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/LayoutEngines/LayoutNode.cs	(revision 10520)
@@ -24,6 +24,9 @@
 using System.Linq;
 
-namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
-  public class LayoutNode<T> where T : class {
+namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
+  public class LayoutNode<T> : object where T : class {
+    public float Width { get; set; }
+    public float Height { get; set; }
+
     public LayoutNode<T> NextLeft {
       get {
@@ -75,4 +78,31 @@
       }
     }
+    /// <summary>
+    /// Translate the position of the layout node according to the given offsets
+    /// </summary>
+    /// <param name="dx"></param>
+    /// <param name="dy"></param>
+    public void Translate(float dx, float dy) {
+      X += dx;
+      Y += dy;
+    }
+
+    public void ResetCoordinates() {
+      X = 0;
+      Y = 0;
+    }
+
+    /// <summary>
+    /// Reset layout-related parameters
+    /// </summary>
+    public void Reset() {
+      Ancestor = this;
+      Thread = null;
+      Change = 0;
+      Shift = 0;
+      Prelim = 0;
+      Mod = 0;
+      ResetCoordinates();
+    }
   }
 }
Index: trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs
===================================================================
--- trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs	(revision 10496)
+++ trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs	(revision 10520)
@@ -5,7 +5,25 @@
 using System.Linq;
 
-namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
-  public class ReingoldTilfordLayoutEngine<T> where T : class {
+namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
+  public class ReingoldTilfordLayoutEngine<T> : ILayoutEngine<T> where T : class {
     private readonly Dictionary<T, LayoutNode<T>> nodeMap; // provides a reverse mapping T => LayoutNode
+    public int NodeWidth { get; set; }
+    public int NodeHeight { get; set; }
+    private int minHorizontalSpacing = 5;
+    public int HorizontalSpacing {
+      get { return minHorizontalSpacing; }
+      set { minHorizontalSpacing = value; }
+    }
+
+    private int minVerticalSpacing = 5;
+    public int VerticalSpacing {
+      get { return minVerticalSpacing; }
+      set { minVerticalSpacing = value; }
+    }
+
+    public Func<T, IEnumerable<T>> GetChildren { get; set; }
+    public Func<T, int> GetLength { get; set; }
+    public Func<T, int> GetDepth { get; set; }
+    private LayoutNode<T> layoutRoot;
 
     public ReingoldTilfordLayoutEngine() {
@@ -13,10 +31,49 @@
     }
 
-    public Dictionary<T, LayoutNode<T>> NodeMap { get { return nodeMap; } }
+    public ReingoldTilfordLayoutEngine(T root, Func<T, IEnumerable<T>> childrenFunc)
+      : this() {
+      Initialize(root, childrenFunc);
+    }
+
+    public void Initialize(T root, Func<T, IEnumerable<T>> getChildren, Func<T, int> getLength = null, Func<T, int> getDepth = null) {
+      GetChildren = getChildren;
+      Clear();
+      var node = new LayoutNode<T> { Content = root, Width = NodeWidth, Height = NodeHeight };
+      node.Ancestor = node;
+      layoutRoot = node;
+      Expand(node);
+    }
+
+    private void Expand(LayoutNode<T> lRoot) {
+      nodeMap.Add(lRoot.Content, lRoot);
+      var children = GetChildren(lRoot.Content).ToList();
+      if (!children.Any()) return;
+      lRoot.Children = new List<LayoutNode<T>>(children.Count);
+      for (int i = 0; i < children.Count; ++i) {
+        var node = new LayoutNode<T> {
+          Content = children[i],
+          Number = i,
+          Parent = lRoot,
+          Level = lRoot.Level + 1,
+          Width = NodeWidth,
+          Height = NodeHeight
+        };
+        node.Ancestor = node;
+        lRoot.Children.Add(node);
+        Expand(node);
+      }
+    }
+
+    public IEnumerable<VisualTreeNode<T>> GetVisualNodes() {
+      return nodeMap.Values.Select(x => new VisualTreeNode<T>(x.Content) {
+        Width = (int)Math.Round(x.Width),
+        Height = (int)Math.Round(x.Height),
+        X = (int)Math.Round(x.X),
+        Y = (int)Math.Round(x.Y)
+      });
+    }
 
     public void AddNode(T content) {
-      if (nodeMap.ContainsKey(content)) {
-        throw new ArgumentException("Content already present in the dictionary.");
-      }
+      if (nodeMap.ContainsKey(content)) { throw new ArgumentException("Content already present in the dictionary."); }
       var node = new LayoutNode<T> { Content = content };
       nodeMap.Add(content, node);
@@ -25,7 +82,5 @@
     public void AddNode(LayoutNode<T> node) {
       var content = node.Content;
-      if (nodeMap.ContainsKey(content)) {
-        throw new ArgumentException("Content already present in the dictionary.");
-      }
+      if (nodeMap.ContainsKey(content)) { throw new ArgumentException("Content already present in the dictionary."); }
       nodeMap.Add(content, node);
     }
@@ -42,80 +97,109 @@
     }
 
-    private float minHorizontalSpacing = 5;
-    public float MinHorizontalSpacing {
-      get { return minHorizontalSpacing; }
-      set { minHorizontalSpacing = value; }
-    }
-
-    private float minVerticalSpacing = 5;
-    public float MinVerticalSpacing {
-      get { return minVerticalSpacing; }
-      set { minVerticalSpacing = value; }
-    }
-
-    private LayoutNode<T> root;
-    public LayoutNode<T> Root {
-      get { return root; }
-      set {
-        root = value;
-      }
-    }
-
     public void ResetCoordinates() {
       foreach (var node in nodeMap.Values) {
-        node.X = 0;
-        node.Y = 0;
-      }
+        node.ResetCoordinates();
+      }
+    }
+
+    public Dictionary<T, PointF> GetCoordinates() {
+      return nodeMap.ToDictionary(x => x.Key, x => new PointF(x.Value.X, x.Value.Y));
     }
 
     /// <summary>
-    /// Transform LayoutNode coordinates so that all coordinates are positive and start from 0.
+    /// Transform LayoutNode coordinates so that all coordinates are positive and start from (0,0)
     /// </summary>
     private void NormalizeCoordinates() {
-      var list = nodeMap.Values.ToList();
+      var nodes = nodeMap.Values.ToList();
       float xmin = 0, ymin = 0;
-      for (int i = 0; i < list.Count; ++i) {
-        if (xmin > list[i].X) xmin = list[i].X;
-        if (ymin > list[i].Y) ymin = list[i].Y;
-      }
-      for (int i = 0; i < list.Count; ++i) {
-        list[i].X -= xmin;
-        list[i].Y -= ymin;
-      }
+      foreach (var node in nodes) {
+        if (xmin > node.X) xmin = node.X;
+        if (ymin > node.Y) ymin = node.Y;
+      }
+      foreach (var node in nodes) {
+        node.X -= xmin;
+        node.Y -= ymin;
+      }
+    }
+
+    public void Center(float width, float height) {
+      // center layout on screen
+      var bounds = Bounds();
+      float dx = 0, dy = 0;
+      if (width > bounds.Width) { dx = (width - bounds.Width) / 2f; }
+      if (height > bounds.Height) { dy = (height - bounds.Height) / 2f; }
+      foreach (var node in nodeMap.Values) { node.Translate(dx, dy); }
+    }
+
+    public void FitToBounds(float width, float height) {
+      var bounds = Bounds();
+      var myWidth = bounds.Width;
+      var myHeight = bounds.Height;
+
+      if (myWidth <= width && myHeight <= height) return; // no need to fit since we are within bounds
+
+      var layers = nodeMap.Values.GroupBy(node => node.Level, node => node).ToList();
+
+      if (myWidth > width) {
+        // need to scale horizontally
+        float x = width / myWidth;
+        foreach (var node in layers.SelectMany(g => g)) {
+          node.X *= x;
+          node.Width *= x;
+        }
+        float spacing = minHorizontalSpacing * x;
+        foreach (var layer in layers) {
+          var nodes = layer.ToList();
+          float minWidth = float.MaxValue;
+          for (int i = 0; i < nodes.Count - 1; ++i) { minWidth = Math.Min(minWidth, nodes[i + 1].X - nodes[i].X); }
+          float w = Math.Min(NodeWidth, minWidth - spacing);
+          foreach (var node in nodes) {
+            node.X += (node.Width - w) / 2f;
+            node.Width = w;
+            //this is a simple solution to ensure that the leftmost and rightmost nodes are not drawn partially offscreen due to scaling and offset
+            //this should work well enough 99.9% of the time with no noticeable visual difference
+            if (node.X < 0) {
+              node.Width += node.X;
+              node.X = 0;
+            } else if (node.X + node.Width > width) {
+              node.Width = width - node.X;
+            }
+          }
+        }
+      }
+      if (myHeight > height) {
+        // need to scale vertically
+        float x = height / myHeight;
+        foreach (var node in layers.SelectMany(g => g)) {
+          node.Y *= x;
+          node.Height *= x;
+        }
+      }
+    }
+
+    public void Clear() {
+      layoutRoot = null;
+      nodeMap.Clear();
     }
 
     public void Reset() {
-      root = null;
-      nodeMap.Clear();
-    }
-
-    public void ResetParameters() {
       foreach (var layoutNode in nodeMap.Values) {
         // reset layout-related parameters 
-        layoutNode.Ancestor = layoutNode;
-        layoutNode.Thread = null;
-        layoutNode.Change = 0;
-        layoutNode.Shift = 0;
-        layoutNode.Prelim = 0;
-        layoutNode.Mod = 0;
+        layoutNode.Reset();
       }
     }
 
     public void CalculateLayout() {
-      if (root == null)
-        throw new Exception("Root cannot be null.");
-      ResetCoordinates(); // reset node X,Y coordinates
-      ResetParameters(); // reset node parameters like Mod, Shift etc. 
-      FirstWalk(root);
-      SecondWalk(root, -root.Prelim);
+      if (layoutRoot == null) throw new Exception("Layout layoutRoot cannot be null.");
+      Reset(); // reset node parameters like Mod, Shift etc. and set coordinates to 0
+      FirstWalk(layoutRoot);
+      SecondWalk(layoutRoot, -layoutRoot.Prelim);
       NormalizeCoordinates();
     }
 
-    /// <summary>
-    /// Returns a map of coordinates for each LayoutNode in the symbolic expression tree.
-    /// </summary>
-    /// <returns></returns>
-    public Dictionary<T, PointF> GetNodeCoordinates() {
-      return nodeMap.ToDictionary(x => x.Key, x => new PointF(x.Value.X, x.Value.Y));
+    public void CalculateLayout(float width, float height) {
+      CalculateLayout();
+      FitToBounds(width, height);
+      Center(width, height);
     }
 
@@ -125,8 +209,8 @@
     /// <returns></returns>
     public RectangleF Bounds() {
-      float xmin, xmax, ymin, ymax; xmin = xmax = ymin = ymax = 0;
+      float xmin = 0, xmax = 0, ymin = 0, ymax = 0;
       var list = nodeMap.Values.ToList();
-      for (int i = 0; i < list.Count; ++i) {
-        float x = list[i].X, y = list[i].Y;
+      foreach (LayoutNode<T> node in list) {
+        float x = node.X, y = node.Y;
         if (xmin > x) xmin = x;
         if (xmax < x) xmax = x;
@@ -134,7 +218,8 @@
         if (ymax < y) ymax = y;
       }
-      return new RectangleF(xmin, ymin, xmax + minHorizontalSpacing, ymax + minVerticalSpacing);
-    }
-
+      return new RectangleF(xmin, ymin, xmax + minHorizontalSpacing + NodeWidth, ymax + minVerticalSpacing + NodeHeight);
+    }
+
+    #region methods specific to the reingold-tilford layout algorithm
     private void FirstWalk(LayoutNode<T> v) {
       LayoutNode<T> w;
@@ -142,5 +227,5 @@
         w = v.LeftSibling;
         if (w != null) {
-          v.Prelim = w.Prelim + minHorizontalSpacing;
+          v.Prelim = w.Prelim + minHorizontalSpacing + NodeWidth;
         }
       } else {
@@ -157,5 +242,5 @@
         w = v.LeftSibling;
         if (w != null) {
-          v.Prelim = w.Prelim + minHorizontalSpacing;
+          v.Prelim = w.Prelim + minHorizontalSpacing + NodeWidth;
           v.Mod = v.Prelim - midPoint;
         } else {
@@ -167,5 +252,5 @@
     private void SecondWalk(LayoutNode<T> v, float m) {
       v.X = v.Prelim + m;
-      v.Y = v.Level * minVerticalSpacing;
+      v.Y = v.Level * (minVerticalSpacing + NodeHeight);
       if (v.IsLeaf) return;
       foreach (var child in v.Children) {
@@ -193,5 +278,5 @@
         vop = vop.NextRight;
         vop.Ancestor = v;
-        float shift = (vim.Prelim + sim) - (vip.Prelim + sip) + minHorizontalSpacing;
+        float shift = (vim.Prelim + sim) - (vip.Prelim + sip) + minHorizontalSpacing + NodeWidth;
         if (shift > 0) {
           var ancestor = Ancestor(vim, v) ?? defaultAncestor;
@@ -244,4 +329,5 @@
       return ancestor.Parent == v.Parent ? ancestor : null;
     }
+    #endregion
   }
 }
Index: trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs
===================================================================
--- trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs	(revision 10496)
+++ 	(revision )
@@ -1,73 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-
-namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
-  // adapter class that provides some conversion methods from symbolic expression trees to layout nodes (preserving the tree structure)
-  public class SymbolicExpressionTreeLayoutAdapter : ILayoutAdapter<ISymbolicExpressionTreeNode> {
-    // default conversion function between ISymbolicExpressionTreeNode and LayoutNode<ISymbolicExpressionTree>
-    LayoutNode<ISymbolicExpressionTreeNode> defaultConvert(ISymbolicExpressionTreeNode node) {
-      var layoutNode = new LayoutNode<ISymbolicExpressionTreeNode> { Content = node };
-      layoutNode.Ancestor = layoutNode;
-      return layoutNode;
-    }
-
-    public IEnumerable<LayoutNode<ISymbolicExpressionTreeNode>> Convert(ISymbolicExpressionTree tree, Func<ISymbolicExpressionTreeNode, LayoutNode<ISymbolicExpressionTreeNode>> convertFunc = null) {
-      return Convert(tree.Root, convertFunc);
-    }
-    // translate the symbolic expression tree structure to a layout node tree structure
-    // return an enumerable containing all the layout nodes
-    public IEnumerable<LayoutNode<ISymbolicExpressionTreeNode>> Convert(ISymbolicExpressionTreeNode root, Func<ISymbolicExpressionTreeNode, LayoutNode<ISymbolicExpressionTreeNode>> convertFunc = null) {
-      var rootLayoutNode = convertFunc == null ? defaultConvert(root) : convertFunc(root);
-      rootLayoutNode.Ancestor = rootLayoutNode;
-
-      if (root.SubtreeCount > 0) {
-        rootLayoutNode.Children = new List<LayoutNode<ISymbolicExpressionTreeNode>>(root.SubtreeCount);
-        Expand(rootLayoutNode, convertFunc);
-      }
-
-      var list = new List<LayoutNode<ISymbolicExpressionTreeNode>> { rootLayoutNode };
-      int i = 0;
-      while (i < list.Count) {
-        if (list[i].Children != null) list.AddRange(list[i].Children);
-        ++i;
-      }
-      return list;
-    }
-
-    private void Expand(LayoutNode<ISymbolicExpressionTreeNode> layoutNode, Func<ISymbolicExpressionTreeNode, LayoutNode<ISymbolicExpressionTreeNode>> convertFunc = null) {
-      if (layoutNode.Children == null) return;
-      for (int i = 0; i < layoutNode.Content.SubtreeCount; ++i) {
-        var subtree = layoutNode.Content.GetSubtree(i);
-        var childLayoutNode = convertFunc == null ? defaultConvert(subtree) : convertFunc(subtree);
-        childLayoutNode.Parent = layoutNode;
-        childLayoutNode.Number = i;
-        childLayoutNode.Level = layoutNode.Level + 1;
-        childLayoutNode.Ancestor = childLayoutNode;
-        childLayoutNode.Children = subtree.SubtreeCount > 0 ? new List<LayoutNode<ISymbolicExpressionTreeNode>>(subtree.SubtreeCount) : null;
-        layoutNode.Children.Add(childLayoutNode);
-        Expand(childLayoutNode, convertFunc);
-      }
-    }
-  }
-}
