def _ReconstructPath(initial_state, current):
 path = collections.deque()
 while current.previous:
  path.appendleft(current)
  current = current.previous
 for node in path:
  initial_state.AddTokenToState(newline=node.newline, dry_run=False)

def _ReconstructPath ( initial_state , current ) : path = collections . deque ( ) while current . previous : path . appendleft ( current ) current = current . previous for node in path : initial_state . AddTokenToState ( newline = node . newline , dry_run = False )
reconstruct the path through the queue with lowest penalty .