      @root = options.root
      @sidenotes = options.sidenotes
 
-    getBreakCost: (node, parent = false) ->
+    getBreakCost: (node) ->
+     if @breakCostMap[node.id]?
+      return @breakCostMap[node.id]
+
      if node.parent()?
       cost = @getBreakCost node.parent(), true
      else

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

      c = @broken[i] + (@getBreakCost inode) + PAGE_COST
      if @broken[n] >= c
       @broken[n] = c
       @nextBreak[n] = i

     for i in @mainNodes
      @broken.push INF
      @nextBreak.push null

     @breakCostMap = {}
     @breakCost = []

     for i in @mainNodes
      @breakCost.push @getBreakCost @map.nodes[i]

     n = @mainNodes.length - 1
     while n >= 1
