def __str__(self):
        """ String representation of a tree (parentheses form) """
        out, stack = [], [self.root]
        while stack:
            node = stack.pop()
            if node == ')':
                out.append(')')
                continue
            out.append('%s(' % str(node))
            stack.append(')')
            for j in xrange(node.refcnt - 1, -1, -1):
                stack.append(node.getLink(j))        
        return ''.join(out)
 String representation of a tree (parentheses form) 
recipes/Python/577898_23_Tree/recipe-577898.py