private Object handleNode(Object name, Map attributes, Object current) {

    attributes = new HashMap(attributes);

    BuilderNode nodeHandler = this.getNode(name.toString());

    if (nodeHandler == null) {
      Class builderClass = (Class) nodeBuilders.get(name);
      if (builderClass != null) {
        nodeHandler = this.getNode("newBuilder");
        attributes.put("class", builderClass);
      }
    }

    if (nodeHandler == null) {
      // we don't know how to handle it - delegate to the decorator.
      return getDecorator().createNode(name, attributes, current);

    } else {
      // We found a handler.

      if (performAttributeValidation) {
        // Validate
        nodeHandler.validateScriptedAttributes(attributes);
      }

      return nodeHandler.createNewNode(current, attributes);
    }
  }
 /**
  * Add's a groovy node handler to the table of possible handlers. If a node handler with the same
  * node name already exists in the map of handlers, then the <tt>GroovyNode</tt> replaces the
  * existing node handler.
  *
  * @param newGroovyNode CustomGroovyNode
  * @return GroovyNodeBuilder to allow for method chaining.
  */
 public synchronized GroovyNodeBuilder setNode(final BuilderNode newGroovyNode) {
   nodeBuilderHandlers.put(newGroovyNode.getNodeName(), newGroovyNode);
   return this;
 }