docs: def format_tree(tree, root=None):
      ''' Tree pretty printer.
      Expects trees to be given as mappings (dictionaries). Keys will be printed; values will be traversed if they are
      mappings. To preserve order, use collections.OrderedDict.
  
      Example:
  
          print format_tree(collections.OrderedDict({'foo': 0, 'bar': {'xyz': 0}}))
  
      '''
      formatted_tree = [root] if root is not None else []
      def _format(tree, prefix='    '):
          nodes = list(tree.keys())
          for i in range(len(nodes)):
              node = nodes[i]
              if i == len(nodes)-1 and len(prefix) > 1:
                  my_prefix = prefix[:-4] + '└── '
                  my_multiline_prefix = prefix[:-4] + '    '
              else:
                  my_prefix = prefix[:-4] + '├── '
                  my_multiline_prefix = prefix[:-4] + '│   '
              n = 0
              for line in node.splitlines():
                  if n == 0:
                      formatted_tree.append(my_prefix + line)
                  else:
                      formatted_tree.append(my_multiline_prefix + line)
                  n += 1
  
              if isinstance(tree[node], collections.Mapping):
                  subprefix = prefix
                  if i < len(nodes)-1 and len(prefix) > 1 and prefix[-4:] == '    ':
                      subprefix = prefix[:-4] + '│   '
                  _format(tree[node], subprefix + '    ')
      _format(tree)
      return '\n'.join(formatted_tree)