protected function groupsConditionalLogic(array $groups = null)
    {
        if (!$groups) {
            $groups = iterator_to_array($this->groups());
        }

        $conditions = [];

        foreach ($groups as $group) {
            if ($group instanceof FormInterface) {
                $groupGroups = iterator_to_array($group->groups());
                if (!empty($groupGroups)) {
                    $conditions = array_merge(
                        $conditions,
                        $this->groupsConditionalLogic($groupGroups)
                    );
                }
            }

            if ($group instanceof FormGroupInterface && $group->conditionalLogic()) {
                $conditions = array_merge($conditions, $group->conditionalLogic());
            }
        }

        return $conditions;
    }