<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def element_for_value(cls, attrname, value):
 """Serialize the given value into an XML `Element` with the given tag name, returning it. The value argument may be: * a `Resource` instance * a `Money` instance * a `datetime.datetime` instance * a string, integer, or boolean value * ``None`` * a list or tuple of these values """

        if isinstance(value, Resource):
            if attrname in cls._classes_for_nodename:
                # override the child's node name with this attribute name
                return value.to_element(attrname)

            return value.to_element()

        el = ElementTreeBuilder.Element(attrname)

        if value is None:
            el.attrib['nil'] = 'nil'
        elif isinstance(value, bool):
            el.attrib['type'] = 'boolean'
            el.text = 'true' if value else 'false'
        elif isinstance(value, int):
            el.attrib['type'] = 'integer'
            el.text = str(value)
        elif isinstance(value, datetime):
            el.attrib['type'] = 'datetime'
            el.text = value.strftime('%Y-%m-%dT%H:%M:%SZ')
        elif isinstance(value, list) or isinstance(value, tuple):
            for sub_resource in value:
                if hasattr(sub_resource, 'to_element'):
                  el.append(sub_resource.to_element())
                else:
                  el.append(cls.element_for_value(re.sub(r"s$", "", attrname), sub_resource))
        elif isinstance(value, Money):
            value.add_to_element(el)
        else:
            el.text = six.text_type(value)

        return el