     public var attributes = [Attribute]()
     public var children: [Node] {
         didSet {
-            for child in children where child.parent !== self {
-                if let oldParent = child.parent,
-                    let childIndex = oldParent.children.index(of: child) {
-                    
-                    oldParent.children.remove(at: childIndex)
-                }
-                child.parent = self
-            }
+            updateParentForChildren()
         }
     }
 

        self.children = children

        super.init(name: name)
    }

    public convenience init(type: StandardElementType, attributes: [Attribute] = [], children: [Node] = []) {
        self.init(name: type.rawValue, attributes: attributes, children: children)
    }
    
    // MARK: - Node Overrides

        return name == rhs.name && attributes == rhs.attributes && children == rhs.children
    }

    // MARK: - Initializers

    public init(name: String, attributes: [Attribute], children: [Node]) {
