nodes: 0, module; 1, function_definition; 2, function_name:CaseGroups; 3, parameters; 4, block; 5, default_parameter; 6, expression_statement; 7, comment:# Dict mapping lowercase code point to fold-equivalent group.; 8, expression_statement; 9, function_definition; 10, expression_statement; 11, expression_statement; 12, for_statement; 13, expression_statement; 14, return_statement; 15, identifier:unicode_dir; 16, identifier:_UNICODE_DIR; 17, comment:"""Returns list of Unicode code groups equivalent under case folding.
  
    Each group is a sorted list of code points,
    and the list of groups is sorted by first code point
    in the group.
  
    Args:
      unicode_dir: Unicode data directory
  
    Returns:
      list of Unicode code groups
    """; 18, assignment; 19, function_name:DoLine; 20, parameters; 21, block; 22, call; 23, assignment; 24, identifier:g; 25, identifier:groups; 26, block; 27, call; 28, expression_list; 29, identifier:togroup; 30, dictionary; 31, identifier:codes; 32, identifier:fields; 33, expression_statement; 34, expression_statement; 35, if_statement; 36, expression_statement; 37, expression_statement; 38, identifier:ReadUnicodeTable; 39, argument_list; 40, identifier:groups; 41, call; 42, expression_statement; 43, attribute; 44, argument_list; 45, identifier:togroup; 46, identifier:groups; 47, comment:"""Process single CaseFolding.txt line, updating togroup."""; 48, assignment; 49, comparison_operator:foldtype not in ("C", "S"); 50, block; 51, assignment; 52, call; 53, binary_operator:unicode_dir+"/CaseFolding.txt"; 54, integer:4; 55, identifier:DoLine; 56, attribute; 57, argument_list; 58, call; 59, identifier:groups; 60, identifier:sort; 61, tuple_pattern; 62, identifier:fields; 63, identifier:foldtype; 64, tuple; 65, return_statement; 66, identifier:lower; 67, call; 68, attribute; 69, argument_list; 70, identifier:unicode_dir; 71, string:"/CaseFolding.txt"; 72, identifier:togroup; 73, identifier:values; 74, attribute; 75, argument_list; 76, identifier:_; 77, identifier:foldtype; 78, identifier:lower; 79, identifier:_; 80, string:"C"; 81, string:"S"; 82, identifier:_UInt; 83, argument_list; 84, call; 85, identifier:extend; 86, identifier:codes; 87, identifier:g; 88, identifier:sort; 89, identifier:lower; 90, attribute; 91, argument_list; 92, identifier:togroup; 93, identifier:setdefault; 94, identifier:lower; 95, list; 96, identifier:lower
code: def CaseGroups(unicode_dir=_UNICODE_DIR):
    """Returns list of Unicode code groups equivalent under case folding.
  
    Each group is a sorted list of code points,
    and the list of groups is sorted by first code point
    in the group.
  
    Args:
      unicode_dir: Unicode data directory
  
    Returns:
      list of Unicode code groups
    """
  
    # Dict mapping lowercase code point to fold-equivalent group.
    togroup = {}
  
    def DoLine(codes, fields):
      """Process single CaseFolding.txt line, updating togroup."""
      (_, foldtype, lower, _) = fields
      if foldtype not in ("C", "S"):
        return
      lower = _UInt(lower)
      togroup.setdefault(lower, [lower]).extend(codes)
  
    ReadUnicodeTable(unicode_dir+"/CaseFolding.txt", 4, DoLine)
  
    groups = togroup.values()
    for g in groups:
      g.sort()
    groups.sort()
    return togroup, groups