code: private function findBySubjectAndStates(StockSubjectInterface $subject, array $states = [])
      {
          $units = [];
  
          // Find by subject oid
          $oid = spl_object_hash($subject);
          if (isset($this->addedUnits[$oid])) {
              $units = $this->addedUnits[$oid];
          }
  
          // Filter by states
          if (!empty($units) && !empty($states)) {
              $units = array_filter($units, function (StockUnitInterface $unit) use ($states) {
                  return in_array($unit->getState(), $states);
              });
          }
  
          return $units;
      }
docs: Finds the suck units by subject and states.
  
  @param StockSubjectInterface $subject
  @param array                 $states
  
  @return array|StockUnitInterface[]