private function checkHasDescendantOfType(Component $comp, $type) { $children = $comp->getChildren(); foreach ($children as $child) { if ($child instanceof $type) { return true; } if ($this->checkHasDescendantOfType($child, $type)) { return true; } } return false; }