def is_valid_name(name, parameters, kw):
    """Checks if name is a valid script variable name. Returns the error."""
    if not name.isidentifier():
        return "Variable name '{}' is not a valid identifier.".format(name)
    if name in kw.KEYWORDS:
        return "Variable name '{}' is a keyword.".format(name)
    behaviors = parameters.get(kw.BEHAVIORS)
    if behaviors is not None and name in behaviors:
        return "Variable name '{}' equals a behavior name.".format(name)
    stimulus_elements = parameters.get(kw.STIMULUS_ELEMENTS)
    if stimulus_elements is not None and name in stimulus_elements:
        return "Variable name '{}' equals a stimulus element name.".format(name)
    return None