public function getAllGroups()
    {
        $result = new \Tx_Oelib_List();
        $groupsToProcess = $this->getGroups();

        do {
            $groupsForNextStep = new \Tx_Oelib_List();
            $result->append($groupsToProcess);
            /** @var \Tx_Oelib_Model_BackEndUserGroup $group */
            foreach ($groupsToProcess as $group) {
                $subgroups = $group->getSubgroups();
                /** @var \Tx_Oelib_Model_BackEndUserGroup $subgroup */
                foreach ($subgroups as $subgroup) {
                    if (!$result->hasUid($subgroup->getUid())) {
                        $groupsForNextStep->add($subgroup);
                    }
                }
            }
            $groupsToProcess = $groupsForNextStep;
        } while (!$groupsToProcess->isEmpty());

        return $result;
    }