/** * Recurse through the container stack * * Recurse through the container stack and call the optimize method for * each child. * * Returns true, if something has been modified, and false otherwise. * * @param slRegularExpression $regularExpression * @return bool */ protected function recurse(slRegularExpression $regularExpression) { if (!$regularExpression instanceof slRegularExpressionContainer) { return false; } $modified = false; $children = $regularExpression->getChildren(); foreach ($children as &$child) { $modified |= $this->optimize($child); } if ($modified) { $regularExpression->setChildren($children); } return (bool) $modified; }