 
         if parent
             node.parent = parent
-            delete node.root
-        else
-            node.root = true
 
         callback?(node)
         return node
+
+
+    DataContextNode.updateAttrs = (node, attrs) ->
+        if node.isBranch()
+            children = node.get('children')
+            for _attrs, i in attrs.children
+                DataContextNode.updateAttrs children[i], _attrs
+        else
+            node.set attrs
 
 
     class DataContext extends Backbone.Model

                return false

            # Check the state of the siblings. If only one sibling is left,
            # promote the parent instead
            node = @parent.remove @
            grand = @parent.parent
            grand.attributes.children.push node
            return @

        add: (nodes...) ->
            if not @isBranch()
                throw new Error 'Node is not a branch. Use "promote" to convert it into one'
            @attributes.children.push.apply @attributes.children, _.map nodes, (attrs) =>
                DataContextNode.parseAttrs attrs, @
            return @

        # Removes itself from it's parent. If a `node` is passed, this
        # implies this node is a branch. When only one sibling remains in the
        # respective branch, the sibling gets demoted.
        remove: ->
            if @root then return false
            children = @parent.attributes.children

            # Ensure the node exists, then splice it directly out of
            # the attributes. This bypasses validation since this operation
            # is recursive.
            if (idx = children.indexOf @) >= 0
                children.splice(idx, 1)[0]
                if children.length is 1
                    children[0].demote()
            return @



                if cache.indexOf(node) is -1
                    cache.push node

        _deferenceNode: (node) =>
            if (cache = @nodes[node.id]) and (idx = cache.indexOf(node)) >= 0
                cache.splice(idx, 1)

        # Returns an array of nodes for the provided `id`.
        getNodes: (id) ->
            @nodes[id] or []

        # Promotes the given `node` to a branch
        promote: (node, nodes...) ->
            if node is null
                @node.promote nodes...
            else
                node.promote nodes...
            @save()

        demote: (node) ->
            node.demote()
            @save()

        add: (node, nodes...) ->
            # Attempt to add to the root node. If the root is empty, so
            # replace it with this node
            if not node
                if @node.isEmpty()
                    @node = nodes[0]
                    @_cacheNode @node
                else
                    node = @node
            if node
                node.add nodes...
                @_cacheNode node for node in node.get 'children'
            @save()

        remove: (node) ->
            node = node or @node
            node.remove()
            if not node.isRoot() then @_deferenceNode node
            @save()


    class DataContexts extends Backbone.Collection
