   addValue: (val) ->
     @values.push val unless @values.indexOf(val) > -1
 
-  getChild: (name) ->
+  getChild: (node) ->
+    name = node.tag
     if @children[name]?
       @children[name].plural on
     else
-      @children[name] = new NodeType name
+      @children[name] = new NodeType node
     @children[name]
 
 analyze = (et) ->
-  root = new NodeType et.tag
+  root = new NodeType et
   analyzeNode root, et
   root
 

# meta-metadata

class NodeType
  constructor: (name) ->
    @name = name
    @isPlural = no
    @values = []
    @children = {}

  if children.length is 0
    this_type.addValue node.text
  else
    analyzeNode this_type.getChild(child), child for child in children

module.exports = analyze
