def indented_list_sort_local(indented_list, indent="    "):
    """
    Given an indented list, i.e., a list of items with indented
    subitems, sorts the items, and the subitems within each item (and so
    on recursively) in case-insensitive alphabetical order.

    >>> indented_list = ["M", " MX", " MG", "D", " DA", " DF", "  DFX", \
    "  DFK", "  DFB", " DC", "K", "X", "H", " HJ", " HB", "A"]
    >>> 
    >>> indented_list = indented_list_sort_local(indented_list, " ")
    >>> indented_list[:8]
    ['A', 'D', ' DA', ' DC', ' DF', '  DFB', '  DFK', '  DFX']
    >>> indented_list[8:]
    ['H', ' HB', ' HJ', 'K', 'M', ' MG', ' MX', 'X']
    """
    KEY, ITEM, CHILDREN = range(3)

    def add_entry(key, item, children):
        nonlocal level
        if level == 0:
            children.append((key, item, []))
        else:
            level -= 1
            add_entry(key, item, children[-1][CHILDREN])

    def update_indented_list(entry):
        indented_list.append(entry[ITEM])
        for subentry in sorted(entry[CHILDREN]):
            update_indented_list(subentry)

    entries = []
    for item in indented_list:
        level = 0
        i = 0
        while item.startswith(indent, i):
            i += len(indent)
            level += 1
        key = item.strip().lower()
        add_entry(key, item, entries)

    indented_list = []
    for entry in sorted(entries):
        update_indented_list(entry)
    return indented_list