Index: trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/FullTreeCreator.cs
===================================================================
--- trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/FullTreeCreator.cs	(revision 7074)
+++ trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/FullTreeCreator.cs	(revision 7076)
@@ -63,5 +63,5 @@
       get { return MaximumSymbolicExpressionTreeDepthParameter.ActualValue; }
     }
-    
+
     public IntValue MaximumSymbolicExpressionTreeLength {
       get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
@@ -107,5 +107,5 @@
 
     public override ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) {
-     return Create(random, grammar, maxTreeLength, maxTreeDepth);
+      return Create(random, grammar, maxTreeLength, maxTreeDepth);
     }
 
@@ -149,5 +149,5 @@
 
       for (var i = 0; i != arity; ++i) {
-        var possibleSymbols = seedNode.Grammar.GetAllowedChildSymbols(seedNode.Symbol,i).Where(s => s.InitialFrequency > 0.0 && seedNode.Grammar.GetMaximumSubtreeCount(s) > 0);
+        var possibleSymbols = seedNode.Grammar.GetAllowedChildSymbols(seedNode.Symbol, i).Where(s => s.InitialFrequency > 0.0 && seedNode.Grammar.GetMaximumSubtreeCount(s) > 0);
         var selectedSymbol = possibleSymbols.SelectRandom(random);
         var tree = selectedSymbol.CreateTreeNode();
@@ -168,9 +168,12 @@
         throw new ArgumentException("Cannot grow node of arity zero. Expected a function node.");
 
+      for (var i = 0; i != arity; ++i) {
+        var possibleSymbols = root.Grammar.GetAllowedChildSymbols(root.Symbol, i);
+        possibleSymbols = possibleSymbols.Where(s => s.InitialFrequency > 0.0 &&
+                                          root.Grammar.GetMinimumExpressionDepth(s) - 1 <= maxDepth - currentDepth &&
+                                          root.Grammar.GetMaximumExpressionDepth(s) > maxDepth - currentDepth);
 
-      for (var i = 0; i != arity; ++i) {
-        var possibleSymbols = currentDepth < maxDepth ?
-          root.Grammar.GetAllowedChildSymbols(root.Symbol,i).Where(s => s.InitialFrequency > 0.0 && root.Grammar.GetMaximumSubtreeCount(s) > 0) :
-          root.Grammar.GetAllowedChildSymbols(root.Symbol,i).Where(s => s.InitialFrequency > 0.0 && root.Grammar.GetMaximumSubtreeCount(s) == 0);
+
+        if (!possibleSymbols.Any()) throw new InvalidOperationException("No symbols are available for the tree.");
         var selectedSymbol = possibleSymbols.SelectRandom(random);
         var tree = selectedSymbol.CreateTreeNode();
Index: trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs
===================================================================
--- trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs	(revision 7074)
+++ trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs	(revision 7076)
@@ -64,5 +64,5 @@
     }
 
-    public IntValue MaximumSymbolicExpressionTreeLength { 
+    public IntValue MaximumSymbolicExpressionTreeLength {
       get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; }
     }
@@ -166,10 +166,9 @@
         throw new ArgumentException("Cannot grow node of arity zero. Expected a function node.");
 
-
       for (var i = 0; i != arity; ++i) {
-        var possibleSymbols = currentDepth < maxDepth
-                                ? root.Grammar.GetAllowedChildSymbols(root.Symbol,i).Where(s => s.InitialFrequency > 0.0)
-                                : root.Grammar.GetAllowedChildSymbols(root.Symbol,i).Where(
-                                  s => s.InitialFrequency > 0.0 && root.Grammar.GetMaximumSubtreeCount(s) == 0);
+        var possibleSymbols = root.Grammar.GetAllowedChildSymbols(root.Symbol, i);
+        possibleSymbols = possibleSymbols.Where(s => s.InitialFrequency > 0.0 &&
+                                          root.Grammar.GetMinimumExpressionDepth(s) - 1 <= maxDepth - currentDepth);
+        if (!possibleSymbols.Any()) throw new InvalidOperationException("No symbols are available for the tree.");
         var selectedSymbol = possibleSymbols.SelectRandom(random);
         var tree = selectedSymbol.CreateTreeNode();
Index: trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionGrammarBase.cs
===================================================================
--- trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionGrammarBase.cs	(revision 7074)
+++ trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionGrammarBase.cs	(revision 7076)
@@ -40,4 +40,5 @@
 
     int GetMinimumExpressionDepth(ISymbol start);
+    int GetMaximumExpressionDepth(ISymbol start);
     int GetMinimumExpressionLength(ISymbol start);
     int GetMaximumExpressionLength(ISymbol start, int maxDepth);
Index: trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs
===================================================================
--- trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs	(revision 7074)
+++ trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs	(revision 7076)
@@ -82,4 +82,5 @@
       cachedMaxExpressionLength = new Dictionary<Tuple<string, int>, int>();
       cachedMinExpressionDepth = new Dictionary<string, int>();
+      cachedMaxExpressionDepth = new Dictionary<string, int>();
 
       cachedIsAllowedChildSymbol = new Dictionary<Tuple<string, string>, bool>();
@@ -94,4 +95,5 @@
       cachedMaxExpressionLength = new Dictionary<Tuple<string, int>, int>();
       cachedMinExpressionDepth = new Dictionary<string, int>();
+      cachedMaxExpressionDepth = new Dictionary<string, int>();
 
       cachedIsAllowedChildSymbol = new Dictionary<Tuple<string, string>, bool>();
@@ -117,4 +119,5 @@
       cachedMaxExpressionLength = new Dictionary<Tuple<string, int>, int>();
       cachedMinExpressionDepth = new Dictionary<string, int>();
+      cachedMaxExpressionDepth = new Dictionary<string, int>();
 
       cachedIsAllowedChildSymbol = new Dictionary<Tuple<string, string>, bool>();
@@ -372,4 +375,5 @@
       cachedMaxExpressionLength.Clear();
       cachedMinExpressionDepth.Clear();
+      cachedMaxExpressionDepth.Clear();
 
       cachedIsAllowedChildSymbol.Clear();
@@ -428,4 +432,20 @@
     }
 
+    private readonly Dictionary<string, int> cachedMaxExpressionDepth;
+    public int GetMaximumExpressionDepth(ISymbol symbol) {
+      int temp;
+      if (!cachedMaxExpressionDepth.TryGetValue(symbol.Name, out temp)) {
+        cachedMaxExpressionDepth[symbol.Name] = int.MaxValue;
+        long maxDepth = 1 + (from argIndex in Enumerable.Range(0, GetMaximumSubtreeCount(symbol))
+                             let maxForSlot = (long)(from s in GetAllowedChildSymbols(symbol, argIndex)
+                                                     where s.InitialFrequency > 0.0
+                                                     select GetMaximumExpressionDepth(s)).DefaultIfEmpty(0).Max()
+                             select maxForSlot).DefaultIfEmpty(0).Max();
+        cachedMaxExpressionDepth[symbol.Name] = (int)Math.Min(maxDepth, int.MaxValue);
+        return cachedMaxExpressionDepth[symbol.Name];
+      }
+      return temp;
+    }
+
     public event EventHandler Changed;
     protected virtual void OnChanged() {
