Find the closest node which is a ShadowRoot or Document by traversing the parentNode ancestry.
ShadowRoot
Document
parentNode
Find the closest node which is a
ShadowRootorDocumentby traversing theparentNodeancestry.