protected function getExistingActiveOrInactiveProduct($existingProduct, $statusId, $locale)
    {
        if (($statusId == StatusEntity::ACTIVE || $statusId == StatusEntity::INACTIVE)
            && $existingProduct->getStatus()->getId() != $statusId
        ) {
            // Check if the same product already exists in IMPORTED state.
            $products = $this->productRepository->findByLocaleAndInternalItemNumber(
                $locale,
                $existingProduct->getInternalItemNumber()
            );
            foreach ($products as $product) {
                if ($product->isDeprecated() && $existingProduct->getId() != $product->getId()) {
                    $product->setIsDeprecated(false);

                    return $this->productFactory->createApiEntity($product, $locale);
                }
            }
        }

        return null;
    }