code: def tree_to_dot(tree):
      g = pydot.Dot(graph_type="digraph")
  
      for node, children in tree.items():
          name = "%s_%03d" % (node, random.randint(0, 999))
          n = pydot.Node(name=name, label=node)
          g.add_node(n)
          add_recurse(g, n, children)
  
      return g
  
imports: import pydot
  import random
label_desc: Use image node_id 2 for calling a global function with example usage: tree_to_dot(tree) and returns: g