'Render in text a class tree as returned by inspect.getclasstree().'

def formattree(self, tree, modname, parent=None, prefix=''):

    result = ''
    for entry in tree:
        if (type(entry) is type(())):
            (c, bases) = entry
            result = ((result + prefix) + classname(c, modname))
            if (bases and (bases != (parent,))):
                parents = map((lambda c, m=modname: classname(c, m)), bases)
                result = (result + ('(%s)' % join(parents, ',    ')))
            result = (result + '\n')
        elif (type(entry) is type([])):
            result = (result + self.formattree(entry, modname, c, (prefix + '                ')))
    return result
