Extra check for DOM fragments in getAncestor method.