code: def treeprint(data, render_only=False, file=None, **options):
      
  
      def getiter(obj):
          if isinstance(obj, collections.abc.Mapping):
              return obj.items()
          elif (isinstance(obj, collections.abc.Iterable) and
                not isinstance(obj, str)):
              return enumerate(obj)
  
      def cycle_check(item, seen=set()):
          item_id = id(item)
          if item_id in seen:
              raise ValueError('Cycle detected for: %s' % repr(item))
          else:
              seen.add(item_id)
  
      def crawl(obj, cc=cycle_check):
          cc(obj)
          objiter = getiter(obj)
          if objiter is None:
              yield TreeNode(obj)
          else:
              for key, item in objiter:
                  if isinstance(item, collections.abc.Iterable) and \
                     not isinstance(item, str):
                      yield TreeNode(key, children=crawl(item))
                  elif item is None:
                      yield TreeNode(key)
                  else:
                      yield TreeNode(key, label=item)
      t = Tree(**options)
      render_gen = t.render(crawl(data))
      if render_only:
          return render_gen
      else:
          file = sys.stdout if file is None else file
          conv = (lambda x: x.plain()) if not file.isatty() else (lambda x: x)
          for x in render_gen:
              print(conv(x), file=file)
docs: Render a tree structure based on generic python containers. The keys
      should be titles and the values are children of the node or None if it's
      an empty leaf node;  Primitives are valid leaf node labels too.  E.g.
  
          sample = {
              "Leaf 1": None,
              "Leaf 2": "I have a label on me",
              "Branch A": {
                  "Sub Leaf 1 with float label": 3.14,
                  "Sub Branch": {
                      "Deep Leaf": None
                  }
              },
              "Branch B": {
                  "Sub Leaf 2": None
              }
          }