private function getReferredParentId($customerId)
    {
        /* use customer ID as parent ID if parent ID cannot be defined */
        $result = $customerId;
        $area = $this->state->getAreaCode();
        if ($area == \Magento\Framework\App\Area::AREA_ADMINHTML) {
            /* use default MLM ID from config */
            $defRootMlmId = $this->hlpConfig->getReferralsRootAnonymous();
            $parent = $this->daoDwnlCust->getByMlmId($defRootMlmId);
            if ($parent) {
                $result = $parent->getCustomerRef();
                $this->logger->info("Default root parent #$result is used for customer #$customerId (admin mode).");
            }
        } else {
            /* try to extract referral code from Mage registry */
            $code = $this->hlpReferral->getReferralCode();
            if ($code) {
                /* this is a referral customer, use parent from referral code */
                $parent = $this->daoDwnlCust->getByReferralCode($code);
                if ($parent) {
                    $result = $parent->getCustomerRef();
                    $this->logger->info("Referral parent #$result is used for customer #$customerId.");
                }
            } else {
                /* this is anonymous customer, use parent from config */
                $anonRootMlmId = $this->hlpConfig->getReferralsRootAnonymous();
                $parent = $this->daoDwnlCust->getByMlmId($anonRootMlmId);
                if ($parent) {
                    $result = $parent->getCustomerRef();
                    $this->logger->info("Anonymous root parent #$result is used for customer #$customerId.");
                }
            }
        }
        return $result;
    }