The isSelected method is defined as an instance method on the LexicalNode class (in packages/lexical/src/LexicalNode.ts). Its purpose is to determine whether "this" node is included in a given selection (or—if no selection is provided—the current selection returned by $getSelection()). In other words, it tells you whether that node is "selected" by comparing its own unique key with the list of node keys that make up the selection.
When isSelected is called, it does the following: