code: public function sameModels($objModel1, $objModel2)
      {
          if (!($objModel1 instanceof Model && $objModel2 instanceof Model)) {
              throw new \InvalidArgumentException('Passed models are not valid.');
          }
  
          $objNative1 = $objModel1->getItem();
          $objNative2 = $objModel2->getItem();
          if ($objNative1->getMetaModel() === $objNative2->getMetaModel()) {
              return true;
          }
          foreach ($objNative1->getMetaModel()->getAttributes() as $objAttribute) {
              if ($objNative1->get($objAttribute->getColName()) != $objNative2->get($objAttribute->getColName())) {
                  return false;
              }
          }
          return true;
      }
docs: Check if two models have the same values in all properties.
  
  @param ModelInterface $objModel1 The first model to compare.
  
  @param ModelInterface $objModel2 The second model to compare.
  
  @return boolean True - If both models are same, false if not.
  
  @throws \InvalidArgumentException If not both models are compatible with this data provider.