 <p>Not the best way, and probably not very good if the tree is big, but you can create a recursive function like :</p> <pre><code>public String ToString() { return id + "{" + a.ToString() + ";" + b.ToString() + "}"; } </code></pre> <p>With : <code>id</code> the id of the current node, <code>a</code> and <code>b</code> the two child</p> <p><strong>EDIT</strong></p> <p>You need to be absolutely sure that this is a tree and that it does not contains any cycle.</p>