title: AttributeError for recursive method in python
body: <p>I have a recursive method problem with python, the code is this:</p>
  
  <pre><code>class NodeTree(object):
      def __init__(self, name, children):
          self.name = name
          self.children = children
  
      def count(self):
          # 1 + i children's nodes
          count = 1
          for c in self.children:
              count += c.count()
          return count
  
  
  def create_tree(d):
      N = NodeTree(d['name'], d['children'])
      print N.count()
  
  d1 = {'name':'musica', 'children':[{'name':'rock', 'children':[{'name':'origini','children':[]},
                                                                 {'name':'rock&amp;roll','children':[]},
                                                                 {'name':'hard rock', 'children':[]}]},
                                     {'name':'jazz', 'children':[{'name':'origini', 'children':[{'name':'1900', 'children':[]}]},
                                                                 {'name':'ragtime', 'children':[]}, {'name':'swing', 'children':[]}]}]}
  tree = create_tree(d1)
  </code></pre>
  
  <p>The error is this:</p>
  
  <pre><code>count += c.count()
  AttributeError: 'dict' object has no attribute 'count'
  </code></pre>
  
  <p>I tried anything but it doesn't work.</p>
  
  <p>Anyway, any suggestions?
  Thanks!</p>