'Create a "pretty print" represenation of the tree with customized indentation at each
level of the tree.'

def pretty(self, root=None, depth=0, spacing=2):

    if (root is None):
        root = self._root
    fmt = ('%s%s/' if root.children else '%s%s')
    s = (fmt % ((('    ' * depth) * spacing), root.text))
    for child in root.children:
        child = root.children[child]
        s += ('\n%s' % self.pretty(child, (depth + 1), spacing))
    return s
