protected function createGroup(String $name, CollectionInterface $principals)
    {

        // initialize the group
        /** \AppserverIo\Psr\Security\Acl\GroupInterface $roles */
        $roles = null;

        // iterate over the passed principals
        foreach ($principals as $principal) {
            // query whether we found a group or not, proceed if not
            if (($principal instanceof GroupInterface) == false) {
                continue;
            }

            // the principal is a group
            $grp = $principal;

            // if the group already exists, stop searching
            if ($grp->getName()->equals($name)) {
                $roles = $grp;
                break;
            }
        }

        // if we did not find a group create one
        if ($roles == null) {
            $roles = new SimpleGroup($name);
            $principals->add($roles);
        }

        // return the group
        return $roles;
    }