/**
  * @param Account $account
  * @param NodeInterface $userStorageNode
  * @param PersonDto $person
  * @return NodeInterface|string
  */
 protected function createProfileNode(Account $account, NodeInterface $userStorageNode, PersonDto $person)
 {
     try {
         $profileNode = $this->findProfileNode($person->getEmailAddress());
         if ($profileNode === NULL) {
             $properties = ['title' => $person->getFirstName() . ' ' . $person->getLastName(), 'firstName' => $person->getFirstName(), 'lastName' => $person->getLastName(), 'address' => $person->getAddress(), 'zipCode' => $person->getZipCode(), 'city' => $person->getCity(), 'emailAddress' => $person->getEmailAddress(), 'phone' => $person->getPhone(), 'dateOfBirth' => $person->getDateOfBirth(), 'jiuJitsu' => $person->getJiuJitsu(), 'buJitsuDo' => $person->getBuJitsuDo(), 'jiuJitsuDegree' => $person->getJiuJitsuDegree(), 'buJitsuDoDegree' => $person->getBuJitsuDoDegree(), 'gender' => $person->getGender()];
             if ($person->getFirstName() && $person->getLastName()) {
                 $nodeName = $person->getFirstName() . ' ' . $person->getLastName();
             }
             $idealNodeName = Utility::renderValidNodeName(isset($nodeName) ? $nodeName : uniqid('node'));
             $idealNodeName = htmlspecialchars($idealNodeName, ENT_NOQUOTES, 'UTF-8');
             $profileNode = $this->nodeWriteRepository->createChildNode($userStorageNode, $idealNodeName, 'BuJitsuDo.Authentication:Person', $properties);
             if ($person->getImage() instanceof Image) {
                 $profileNode = $this->profileService->setImageToNode($profileNode, $person->getImage(), $person->getFirstName(), 'Profile images');
             }
         }
         $account->getParty()->getPreferences()->set('profileNodeIdentifier', $profileNode->getIdentifier());
         $this->partyRepository->update($account->getParty());
         $this->persistenceManager->persistAll();
         $this->emitPersonCreated($profileNode);
         return $profileNode;
     } catch (\Exception $exception) {
         $this->systemLogger->log('Profile node could not be created because: ' . $exception->getMessage(), LOG_CRIT);
         return $exception->getMessage();
     }
 }