/**
  * The slot for the signal in DatabaseTreeDataProvider.
  *
  * @param DatabaseTreeDataProvider $dataProvider
  * @param TreeNode $treeData
  * @return void
  */
 public function addUserPermissionsToCategoryTreeData(DatabaseTreeDataProvider $dataProvider, $treeData)
 {
     if (!$this->backendUserAuthentication->isAdmin() && $dataProvider->getTableName() === $this->categoryTableName) {
         // Get User permissions related to category
         $categoryMountPoints = $this->backendUserAuthentication->getCategoryMountPoints();
         // Backup child nodes to be processed.
         $treeNodeCollection = $treeData->getChildNodes();
         if (!empty($categoryMountPoints) && !empty($treeNodeCollection)) {
             // First, remove all child nodes which must be analysed to be considered as "secure".
             // The nodes were backed up in variable $treeNodeCollection beforehand.
             $treeData->removeChildNodes();
             // Create an empty tree node collection to receive the secured nodes.
             /** @var TreeNodeCollection $securedTreeNodeCollection */
             $securedTreeNodeCollection = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\TreeNodeCollection');
             foreach ($categoryMountPoints as $categoryMountPoint) {
                 $treeNode = $this->lookUpCategoryMountPointInTreeNodes((int) $categoryMountPoint, $treeNodeCollection);
                 if (!is_null($treeNode)) {
                     $securedTreeNodeCollection->append($treeNode);
                 }
             }
             // Reset child nodes.
             $treeData->setChildNodes($securedTreeNodeCollection);
         }
     }
 }