Return all sub node types of a node type (recursively)

@param string $type
@return array
344656
protected function getAllSubtypes($type)
    {
        $subTypes = [];

        foreach ($this->superTypeConfiguration as $nodeType => $superTypes) {
            if (in_array($type, $superTypes)) {
                if (isset($this->types[$nodeType])) {
                    $subTypes[] = $nodeType;

                    $nodeTypeSubTypes = $this->getAllSubtypes($nodeType);
                    foreach ($nodeTypeSubTypes as $nodeTypeSubType) {
                        if (!in_array($nodeTypeSubType, $subTypes)) {
                            $subTypes[] = $nodeTypeSubType;
                        }
                    }
                }
            }
        }

        return $subTypes;
    }
297300
public function get(string $type): array
    {
        if (!isset($this->values[$type])) {
            return [];
        }

        return $this->values[$type];
    }
1257531
private static function getTyped($type)
    {
        if (!isset(static::$types[$type])) {
            static::$types[$type] = new self($type);
        }

        return static::$types[$type];
    }
940598
private function resolveTypes($type)
    {
        $filterTypes = [];

        do {
            $filterTypes[] = $filterType = $this->filterRegistry[$type];
        } while (($type = $filterType->getParent()) !== null);

        return $filterTypes;
    }
1029563
protected function getSuggestedTypes($type)
    {
        $mapping = [
            'void'    => false,
            'mixed'   => false,
            'null'    => false,
            'int'     => 'int',
            'integer' => 'int',
            'string'  => 'string',
            'float'   => 'float',
            'bool'    => 'bool',
            'boolean' => 'bool',
        ];

        $typeNames = explode('|', $type);
        return array_unique(
            array_map(
                function ($typeName) use ($mapping) {
                    if (isset($mapping[$typeName])) {
                        return $mapping[$typeName];
                    }

                    if ($this->isTypeArray($typeName)) {
                        return 'array';
                    }

                    if ($this->isTypeCallable($typeName)) {
                        return 'callable';
                    }

                    if ($this->isTypeObject($typeName)) {
                        return $typeName;
                    }

                    return false;
                },
                $typeNames
            )
        );
    }
837402
protected function _allOfType(int $type): array
    {
        return array_values(
            array_filter($this->_targets,
                function (Target $target) use ($type) {
                    return $target->type() == $type;
                }));
    }
347913
private function getGroupTypeInfo($type)
    {
        $search = $this->repository->createSearch();
        $search->addAggregation(new TermsAggregation($type, $type));
        $result = $this->repository->findDocuments($search);
        $aggregation = $result->getAggregation($type);
        $items = [];

        foreach ($aggregation as $item) {
            $items[] = $item['key'];
        }

        return $items;
    }
1062778
public function getXSDType($type)
    {
        if ($this->isXDSType($type)) {
            return self::$XSDTypes[strtolower($type)];
        } elseif ($type) {
            if (strpos($type, '[]')) {
                if ($this->isXDSType(str_replace('[]', '', $type))) {
                    return self::$XSDTypes['array'];
                }
            }

            return $this->addComplexType($type);
        } else {
            return null;
        }
    }
1136100
public function findAllowedParents(Elementtype $elementtype)
    {
        $elementtypes = [];
        foreach ($this->viabilityManager->findAllowedParents($elementtype) as $viability) {
            $elementtypes[] = $this->elementSourceManager->findElementtype($viability->getUnderElementtypeId());
        }

        return $elementtypes;
    }
178006
public function findComponentsByType($type)
    {
        $components = [];
        foreach ($this->components as $component) {
            if ($component->hasType($type)) {
                $components[] = $component;
            }
        }

        return $components;
    }
646322
public static function getSubTypeList($type) {
        if (empty(self::$_subTypes[$type])) {
            throw new InvalidArgumentException(sprintf('Sub-type %s does not exist', $type));
        }

        $types = array();

        foreach (self::$_subTypes[$type] as $ext) {
            $types[$ext] = self::getTypeFromExt($ext);
        }

        return $types;
    }
135676
protected function getNodeClass($type)
    {
        $type = strtolower($type);

        if (!isset($this->nodeMapping[$type])) {
            throw new \RuntimeException(sprintf('The node type "%s" is not registered.', $type));
        }

        $class = $this->nodeMapping[$type];

        if (!class_exists($class)) {
            throw new \RuntimeException(sprintf('The node class "%s" does not exist.', $class));
        }

        return $class;
    }
604442
public function all($type = null)
    {
        return array_filter(
            $this->bag,
            /** @var BuilderInterface $builder */
            function (BuilderInterface $builder) use ($type) {
                return $type === null || $builder->getType() == $type;
            }
        );
    }
994510
public function getObjectsByType($type, $subtype = null)
    {
        $objects = array();

        foreach ($this->objects as $id => $object) {
            if ($object->getHeader()->get('Type') == $type &&
                (is_null($subtype) || $object->getHeader()->get('Subtype') == $subtype)
            ) {
                $objects[$id] = $object;
            }
        }

        return $objects;
    }
102546
public static function getSubType($type)
    {
        if (preg_match('/^(.+)\[\]$/', $type, $matches) || preg_match('/^_(.+)$/', $type, $matches)) {
            return $matches[1];
        }

        return $type;
    }
206873
public function fetchAll($type = parent::FETCH_TYPE_NUM)
    {
        return array_map($this->_callback, $this->_statement->fetchAll($type));
    }
76232
protected function getTypeByCode($type)
    {
        switch ($type) {
            case self::BOOLEAN:
                return 'boolean';
            case self::INT:
                return 'int';
            case self::FLOAT:
                return 'float';
            case self::STRING:
                return 'string';
            case self::DATE:
                return 'date';
            case self::OBJECT:
                return 'object';
            case self::XML:
                return 'xml';
            case self::DATA:
                return 'data';
            case self::DATA_ARRAY:
                return 'array';

            default:
                return null;
        }
    }