title: How to visually print a NON binary tree?
body: <p>I made a basic tree where all the nodes have a name and a set of children.</p>
  
  <pre><code>public class Tree {
      String data;
      Tree parent = null;
      HashSet children = new HashSet();
  
      public Tree(String nodeName) {
          this.data = nodeName;
      }
  
      public void parent(Tree parent) {
          this.parent = parent
      }
  
      public void addAChild(Tree child) {
          this.children.add(child);
          child.parent(this);
      }
  </code></pre>
  
  <p>And to use this class</p>
  
  <pre><code>Tree a = new Tree("root");
  Tree b = new Tree("n1");
  Tree c = new Tree("n2");
  Tree d = new Tree("n3");
  Tree e = new Tree("n4");
  Tree f = new Tree("n5");
  
  a.addAChild(b);
  a.addAChild(c);
  a.addAChild(d);
  
  d.addAChild(e);
  e.addAChild(f);
  </code></pre>
  
  <p>This makes sense to me but I'd like a visual representation of the tree so that I can quickly test to see if the children and nodes are in the right place.</p>
  
  <p>I'm trying to make the output look like this:<a href="https://i.stack.imgur.com/UVtuK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UVtuK.png" alt="enter image description here"></a></p>
  
  <p>Or something similar.  </p>