public Collection<String> getTypeNamesForImportStatements(TypeDefinition baseType, Set<String> nonSimpleTypeReferences) {
        // We add ourselves to avoid a stackoverflow
        nonSimpleTypeReferences.add(baseType.getName());
        // If it's a complex type definition, add all the types referenced by any property fields
        // (Includes any types referenced by subtypes in case this is a discriminated type parent)
        if (baseType.isComplexTypeDefinition()) {
            ComplexTypeDefinition complexTypeDefinition = baseType.asComplexTypeDefinition().orElseThrow();
            for (Field field : complexTypeDefinition.getFields()) {
                if (field.isPropertyField()) {
                    PropertyField propertyField = field.asPropertyField().orElseThrow();
                    TypeReference typeReference = propertyField.getType();
                    if (typeReference.isArrayTypeReference()) {
                        typeReference = typeReference.asArrayTypeReference().orElseThrow().getElementTypeReference();
                    }
                    if (typeReference.isNonSimpleTypeReference()) {
                        NonSimpleTypeReference nonSimpleTypeReference = typeReference.asNonSimpleTypeReference().orElseThrow();
                        if(nonSimpleTypeReference.getTypeDefinition().isDiscriminatedComplexTypeDefinition()) {
                            final Optional<DiscriminatedComplexTypeDefinition> discriminatedComplexTypeDefinition = nonSimpleTypeReference.getTypeDefinition().asDiscriminatedComplexTypeDefinition();
                            if(discriminatedComplexTypeDefinition.orElseThrow().isDiscriminatedChildTypeDefinition()) {
                                final ComplexTypeDefinition complexTypeDefinition1 = discriminatedComplexTypeDefinition.orElseThrow().getParentType().orElseThrow();
                                nonSimpleTypeReferences.add(complexTypeDefinition1.getName());
                            }
                        } else {
                            nonSimpleTypeReferences.add(nonSimpleTypeReference.getTypeDefinition().getName());
                        }
                    }
                } else if (field.isSwitchField()) {
                    SwitchField switchField = field.asSwitchField().orElseThrow();
                    for (DiscriminatedComplexTypeDefinition switchCase : switchField.getCases()) {
                        if (nonSimpleTypeReferences.contains(switchCase.getName())) {
                            continue;
                        }
                        nonSimpleTypeReferences.addAll(getTypeNamesForImportStatements(switchCase, nonSimpleTypeReferences));
                    }
                }
            }
        } else if (baseType.isEnumTypeDefinition()) {// In case this is an enum type, we have to check all the constant types.
            EnumTypeDefinition enumTypeDefinition = baseType.asEnumTypeDefinition().orElseThrow();
            for (String constantName : enumTypeDefinition.getConstantNames()) {
                final TypeReference constantType = enumTypeDefinition.getConstantType(constantName);
                if (constantType.isNonSimpleTypeReference()) {
                    NonSimpleTypeReference nonSimpleTypeReference = constantType.asNonSimpleTypeReference().orElseThrow();
                    nonSimpleTypeReferences.add(nonSimpleTypeReference.getName());
                }
            }
        }
        // If the type has any parser arguments, these have to be checked too.
        baseType.getParserArguments().ifPresent(arguments -> arguments.stream()
            .map(Argument::getType)
            .map(TypeReferenceConversions::asNonSimpleTypeReference)
            .filter(Optional::isPresent)
            .map(Optional::get)
            .map(NonSimpleTypeReference::getName)
            .forEach(nonSimpleTypeReferences::add)
        );

        // We remove ourselves to avoid a stackoverflow
        nonSimpleTypeReferences.remove(baseType.getName());
        return nonSimpleTypeReferences;
    }
Helper for collecting referenced non simple types as these usually need to be
imported in some way.

@param baseType the base type we want to get the type references from
@return collection of non simple type references used in the type.
code-generation/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageTemplateHelper.java