private function getTreeNodes(
        $lang,
        $permission,
        AclNativeHelper $aclNativeHelper,
        $includeHiddenFromNav
    ) {
        if (null === $this->treeNodes) {
            $repo = $this->em->getRepository('KunstmaanNodeBundle:Node');
            $this->treeNodes = [];

            $rootNode = $this->domainConfiguration->getRootNode();

            // Get all nodes that should be shown in the menu
            $allNodes = $repo->getAllMenuNodes(
                $lang,
                $permission,
                $aclNativeHelper,
                $includeHiddenFromNav,
                $rootNode
            );
            /** @var Node $nodeInfo */
            foreach ($allNodes as $nodeInfo) {
                $refEntityName = $nodeInfo['ref_entity_name'];
                if ($this->pagesConfiguration->isHiddenFromTree($refEntityName)) {
                    continue;
                }
                $parent_id = is_null($nodeInfo['parent']) ? 0 : $nodeInfo['parent'];
                unset($nodeInfo['parent']);
                $this->treeNodes[$parent_id][] = $nodeInfo;
            }
            unset($allNodes);
        }

        return $this->treeNodes;
    }