def pretty_tree_from_tree(tree, indent_width=2):
 INDENT = (' ' * indent_width)
 def _prettify(elem, indent_level=0):
  if elem:
   elem.text = ('\n' + (INDENT * (indent_level + 1)))
   for child in elem:
    _prettify(child, (indent_level + 1))
   elem[(-1)].tail = ('\n' + (INDENT * indent_level))
   elem.tail = ('\n' + (INDENT * indent_level))
  else:
   elem.text = None
   elem.tail = ('\n' + (INDENT * indent_level))
 _prettify(tree)
 return tree

def pretty_tree_from_tree ( tree , indent_width = 2 ) : INDENT = ( ' ' * indent_width ) def _prettify ( elem , indent_level = 0 ) : if elem : elem . text = ( '\n' + ( INDENT * ( indent_level + 1 ) ) ) for child in elem : _prettify ( child , ( indent_level + 1 ) ) elem [ ( - 1 ) ] . tail = ( '\n' + ( INDENT * indent_level ) ) elem . tail = ( '\n' + ( INDENT * indent_level ) ) else : elem . text = None elem . tail = ( '\n' + ( INDENT * indent_level ) ) _prettify ( tree ) return tree
add appropriate .