human
Solve the following python programming problem given the following code:
@register.filter(is_safe=True, needs_autoescape=True)
def unordered_list(value, autoescape=True):
assistant
#Here is the Python program you requested.

    """Recursively take a self-nested list and return an HTML unordered list --
    WITHOUT opening and closing <ul> tags.
    Assume the list is in the proper format. For example, if ``var`` contains:
    ``[\States\, [\Kansas\, [\Lawrence\, \Topeka\], \Illinois\]]``, then
    ``{{ var|unordered_list }}`` returns::
    <li>States
    <ul>
    <li>Kansas
    <ul>
    <li>Lawrence</li>
    <li>Topeka</li>
    </ul>
    </li>
    <li>Illinois</li>
    </ul>
    </li>
    """
    if autoescape:
        escaper = conditional_escape
    else:
        def escaper(x):
            return x
    def walk_items(item_list):
        item_iterator = iter(item_list)
        with suppress(StopIteration):
            item = next(item_iterator)
            while True:
                try:
                    next_item = next(item_iterator)
                except StopIteration:
                    (yield (item, None))
                    break
                if (not isinstance(next_item, str)):
                    try:
                        iter(next_item)
                    except TypeError:
                        pass
                    else:
                        (yield (item, next_item))
                        item = next(item_iterator)
                        continue
                (yield (item, None))
                item = next_item
    def list_formatter(item_list, tabs=1):
        indent = (' DCTB ' * tabs)
        output = []
        for (item, children) in walk_items(item_list):
            sublist = ''
            if children:
                sublist = ('\n%s<ul>\n%s\n%s</ul>\n%s' % (indent, list_formatter(children, (tabs + 1)), indent, indent))
            output.append(('%s<li>%s%s</li>' % (indent, escaper(item), sublist)))
        return '\n'.join(output)
    return mark_safe(list_formatter(value))