 define (require) ->
   h = require('../helper')
 
+  _nodelog = (node, message...) =>
+    depth = h.depth(node) + 0
+    indent = ""
+    x = 0
+    while x < depth
+      indent += "| "
+      x += 1
+    if indent.length
+      message.unshift indent
+    console.log.apply(console, message)
+
   getPattern = (node, defines) =>
     if node instanceof Pattern or node instanceof NameClass
       return node

      if attrCheck instanceof NotAllowed
        return attrCheck
      if descend
        console.log "let's check descent: #{descend}, #{node.childNodes?.length}", this, node
        descend = descend - 1
        nextPattern = @pattern
        if node.childNodes?.length
          for child in node.childNodes
            if h.getNodeType(child) is Node.TEXT_NODE and h.textContent(child).replace(/^\s+|\s+$/gm, "") is ""
              console.log "skipping empty text node"
              continue
            console.log "==> checking child", child, "against", nextPattern
            nextPattern = nextPattern.check(child, descend)
            console.log "child result of", child, "was", nextPattern
            if nextPattern instanceof NotAllowed
              return nextPattern

      return new GoodElement(@name, @pattern)




      "element #{@name} { #{@pattern} }"
    _check: (node, descend = false) =>
      nameCheck = @name.contains node
      _nodelog node, "Namechecking", node, "against", @name, "result", nameCheck
      if not nameCheck
        return new NotAllowed("name check failed - expecting #{@name}, found #{h.getLocalName(node)}", @name, node)
      if nameCheck instanceof NotAllowed
