public boolean requiresVariable(Field curField, String variable) {
        if (curField.isArrayField()) {
            ArrayField arrayField = (ArrayField) curField;
            // Check if the loop expression of the array field contains the variable
            // name.
            if (arrayField.getLoopExpression().contains(variable)) {
                return true;
            }
        } else if (curField.isOptionalField()) {
            // Check if the optional field has a condition expression that contains
            // the variable name.
            OptionalField optionalField = (OptionalField) curField;
            if (optionalField.getConditionExpression().isPresent() &&
                optionalField.getConditionExpression().orElseThrow(IllegalStateException::new).contains(variable)) {
                return true;
            }
        }
        // Check if the type reference of the field's type has a parameter that
        // contains the variable name.
        return curField.asTypedField()
            .map(typedField -> typedField.getType().asNonSimpleTypeReference()
                .map(nonSimpleTypeReference -> nonSimpleTypeReference.getParams()
                    .map(params -> params.stream()
                        // Stream over all parameters of the type reference and
                        // returns true if any of them contains the variable name.
                        .anyMatch(param -> param.contains(variable))
                    )
                    .orElse(false)
                )
                .orElse(false)
            )
            .orElse(false);
    }
Checks whether a given field requires a variable.

@param curField the field to check
@param variable the variable to check for
@return true if the field requires the variable, false otherwise
code-generation/language-python/src/main/java/org/apache/plc4x/language/python/PythonLanguageTemplateHelper.java