getRootNode

fun getRootNode(options: GetRootNodeOptions = definedExternally): Node(source)

The getRootNode() method of the Node interface returns the context object's root, which optionally includes the shadow root if it is available.

MDN Reference