How to check if a multi value reference field already has a value

I need to check if a multi-valued reference field (referencing other nodes) in a node has a specific value already present to avoid duplicates. here is the code: $portFolioNode = \Drupal\node\Entity\Node::load( $form_state->getValues()[‘portfolios’] ); //now save location id to reference field. //$portFolioNode->field_portfolio_locations[] = [‘target_id’ => $form_state->getValues()[‘location_nid’] ]; // how can I check if location_nid is present…