code: def fixup_parents(self, node, parent):
          
          start, finish = 0, self.last_finish
          # We assume anything with a start has a finish.
          needs_range = not hasattr(node, 'start')
  
          if not hasattr(node, 'parent'):
              node.parent = parent
  
          for n in node:
              if needs_range and hasattr(n, 'start'):
                  if n.start < start: start = n.start
                  if n.finish > finish: finish = n.finish
  
              if hasattr(n, 'offset') and not hasattr(n, 'parent'):
                  n.parent = node
              else:
                  self.fixup_parents(n, node)
                  pass
              pass
          if needs_range:
              node.start, node.finish = start, finish
  
          return
docs: Make sure each node has a parent