       cost = 0
 
      if BREAK_COST[node.type]?
-      return cost + BREAK_COST[node.type]
-
-     if node.type is 'section'
-      if not parent
-       switch node.level
-        when 1
-         cost -= 1500
-        when 2
-         cost -= 1000
-        when 3
-         cost -= 100
-
-       return cost
-      return cost + 100 * (node.level - 2)
-
-
-     throw new Error 'Unknown type'
+      @breakCostMap[node.id] = cost + BREAK_COST[node.type]
+     else if node.type is 'section'
+      @breakCostMap[node.id] = cost + 100 * (node.level - 2)
+     else
+      throw new Error 'Unknown type'
+
+     return @breakCostMap[node.id]
 
 
     getOffsetTop: (elem, parent) ->

     @root = options.root
     @sidenotes = options.sidenotes

    getBreakCost: (node, parent = false) ->
     if node.parent()?
      cost = @getBreakCost node.parent(), true
     else

            (@getOffsetTop elem, @elems.main)
      break if pos > H

      c = @broken[i] + @breakCost[i] + PAGE_COST
      if @broken[n] >= c
       @broken[n] = c
       @nextBreak[n] = i
