diff --git a/add_curve_sapling/utils.py b/add_curve_sapling/utils.py
index d9868749b0ff4044db1b056b194d36a322e3afa7..59b792193534eaecdbe1b13d5171463ca0aab14b 100644
--- a/add_curve_sapling/utils.py
+++ b/add_curve_sapling/utils.py
@@ -589,7 +589,7 @@ def addTree(props):
                         childStems = branches[2]*(0.2 + 0.8*(branchL/p.lengthPar)/lMax)
                     elif storeN <= levels - 2:
                         branchL = (length[n] + uniform(-lengthV[n],lengthV[n]))*(p.lengthPar - 0.6*p.offset)
-                        childStems = branches[n+1]*(1.0 - 0.5*p.offset/p.lengthPar)
+                        childStems = branches[min(3,n+1)]*(1.0 - 0.5*p.offset/p.lengthPar)
                     # If this is the last level before leaves then we need to generate the child points differently
                     else:
                         branchL = (length[n] + uniform(-lengthV[n],lengthV[n]))*(p.lengthPar - 0.6*p.offset)
@@ -915,4 +915,4 @@ def addTree(props):
             for p in armOb.pose.bones:
                 p.rotation_mode = 'XYZ'
             treeOb.parent = armOb
-        #print(time.time()-startTime)
+        #print(time.time()-startTime)
\ No newline at end of file