def to_tree(instance, *children):
    """
    Generate tree structure of an instance, and its children. This method
    yields its results, instead of returning them.
    """

    # Yield representation of self
    yield unicode(instance)

    # Iterate trough each instance child collection
    for i, child in enumerate(children):
        lines = 0

        yield "|"
        yield "+---" + unicode(child)

        if i != len(children) - 1:
            a = "|"
        else:
            a = " "

        # Iterate trough all values of collection of child
        for j, item in enumerate(child.itervalues()):
            if j != len(child) - 1:
                b = "|"
            else:
                b = " "

            if j == 0:
                yield a + "   |"

            # Append prefix to each line
            for k, line in enumerate(item.to_tree()):
                lines += 1

                if k == 0:
                    yield a + "   +---" + line
                else:
                    yield a + "   " + b + "   " + line

        # Add extra space if required
        if 1 > len(children) and i == len(children) - 1 and lines > 1:
            yield a
dataset/ETHPy150Open basilfx/flask-daapserver/daapserver/utils.py/to_tree/swapped operands of `>`