'Prints out this spec and its dependencies, tree-formatted
with indentation.'

def tree(self, **kwargs):

    color = kwargs.pop('color', get_color_when())
    depth = kwargs.pop('depth', False)
    hashes = kwargs.pop('hashes', False)
    hlen = kwargs.pop('hashlen', None)
    install_status = kwargs.pop('install_status', False)
    cover = kwargs.pop('cover', 'nodes')
    indent = kwargs.pop('indent', 0)
    fmt = kwargs.pop('format', '$_$@$%@+$+$=')
    prefix = kwargs.pop('prefix', None)
    show_types = kwargs.pop('show_types', False)
    deptypes = kwargs.pop('deptypes', ('build', 'link'))
    check_kwargs(kwargs, self.tree)
    out = ''
    for (d, dep_spec) in self.traverse_edges(order='pre', cover=cover, depth=True, deptypes=deptypes):
        node = dep_spec.spec
        if (prefix is not None):
            out += prefix(node)
        out += ('    ' * indent)
        if depth:
            out += ('%-4d' % d)
        if install_status:
            status = node._install_status()
            if (status is None):
                out += '                    '
            elif status:
                out += colorize('@g{[+]}        ', color=color)
            else:
                out += colorize('@r{[-]}        ', color=color)
        if hashes:
            out += (colorize('@K{%s}        ', color=color) % node.dag_hash(hlen))
        if show_types:
            out += '['
            if dep_spec.deptypes:
                for t in alldeps:
                    out += ''.join((t[0] if (t in dep_spec.deptypes) else '    '))
            else:
                out += ('    ' * len(alldeps))
            out += ']        '
        out += ('                ' * d)
        if (d > 0):
            out += '^'
        out += (node.format(fmt, color=color) + '\n')
    return out
