public void setRoot(SpanNode root) {
        if (!root.isValid()) {
            throw new IllegalStateException("Cannot use invalid node " + root + " as root node.");
        }
        if (root.getParent() != null) {
            if (root.getParent() != this) {
                throw new IllegalStateException(root + " is already a child of " + root.getParent() + ", cannot be root of " + this);
            }
        }
        this.root = root;
        root.setParent(this);
    }
WARNING!&nbsp;Only to be used by deserializers!&nbsp;Sets the root of this SpanTree instance.

@param root the root to set for this SpanTree instance.
document/src/main/java/com/yahoo/document/annotation/SpanTree.java