code: def insert_group(node, target):
      
      group = target.sort
      lang = target.lang
  
      collator = Collator.createInstance(Locale(lang) if lang else Locale())
      for child in target.tree:
          order = collator.compare(group(child) or '', group(node) or '')
          if order == 0:
              for nodechild in node[1:]:
                  child.append(nodechild)
              break
          elif order > 0:
              child.addprevious(node)
              break
      else:
          target.tree.append(node)
docs: Insert node into in target tree, in appropriate group.
  
      Uses group and lang from target function.  This assumes the node and
      target share a structure of a first child that determines the grouping,
      and a second child that will be accumulated in the group.