protected function collapsePermissions()
    {
        foreach ($this->modulePresences as $moduleKey => $presences) {

            if ( ! array_key_exists($moduleKey, $this->modulePermissions)) {
                $this->modulePermissions[ $moduleKey ] = [];
            }

            /** @var AclPresenceInterface[] $presences */
            foreach ($presences as $presence) {

                if ( ! count($presence->permissions())) {
                    continue;
                }

                $flatPermissions = $presence->permissions();

                $this->permissions                   = array_merge($this->permissions, $flatPermissions);
                $this->modulePermissions[$moduleKey] = array_merge($this->modulePermissions[$moduleKey], $flatPermissions);
            }
        }

        $this->permissions = array_unique($this->permissions);

        return $this;
    }