The Selection.containsNode() method indicates whether a specified node is part of the selection.
Selection.containsNode()
MDN Reference