Traversing a non-binary tree
<p>I've made custom class for nodes</p>

<pre><code>class NodeTree(object):
    def __init__(self, name = None, children = None):
        self.name = name
        self.children = children
</code></pre>

<p>and defined a function that make a tree(a node containing its children nodes)</p>

<pre><code>def create_tree(d):
    x = NodeTree()
    for a in d.keys():
        if type(d[a]) == str:
            x.name = d[a]
        if type(d[a]) == list:
            if d[a] != []:
                for b in d[a]:
                    x.add_child(create_tree(b))
    return x
</code></pre>

<p>The input is a dict with one argument for the node name and a list with its children in the same form as the parent.
The function work fine and I've made method that prove it but I can't find a way to traverse it right and get the height of the tree. I don't know if "height" it's the right term cause I know it may be ambivalent, I need to count the node as a measure unit, like this:</p>

<pre><code>                                      parent
                                         |
                                         |
                                     ---------
                                     |       |
                                    child   child
</code></pre>

<p>The height of this tree is 2, I've tried everything, from counters to tag in the class, everything seems to degenerate an I never get the right height.
How should I approach that?</p>
