public boolean needsVariable(Field field, String variableName, boolean serialization) {
        // If it's not a serialization, check if the field is an array and the loop
        // expression contains the variable name, or if it's a virtual field and
        // the value expression contains the variable name.
        if (!serialization) {
            if (field instanceof ArrayField) {
                ArrayField arrayField = (ArrayField) field;
                if (arrayField.getLoopExpression().contains(variableName)) {
                    return true;
                }
            }
        }
        // If it's not a serialization, check if the field is a virtual field and
        // the value expression contains the variable name.
        if (field instanceof VirtualField) {
            VirtualField virtualField = (VirtualField) field;
            if (virtualField.getValueExpression().contains(variableName)) {
                return true;
            }
        }
        // If it's not a serialization, check if the field is a padding field and
        // the padding condition or padding value expression contains the variable
        // name.
        if (field instanceof PaddingField) {
            PaddingField paddingField = (PaddingField) field;
            if (paddingField.getPaddingCondition().contains(variableName)) {
                return true;
            }
            if (paddingField.getPaddingValue().contains(variableName)) {
                return true;
            }
        }
        // Otherwise, check if the field's type reference has a parameter that
        // contains the variable name.
        return field.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(variableName))
                    )
                    .orElse(false)
                )
                .orElse(false)
            )
            .orElse(false);
    }
Checks whether a given field requires a variable.

@param field the field to check
@param variable the variable to check for
@param serialization whether the field is used in serialization or not
@return true if the field requires the variable, false otherwise
code-generation/language-python/src/main/java/org/apache/plc4x/language/python/PythonLanguageTemplateHelper.java