<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ensure_security_header(envelope, queue):
 """Insert a security XML node if it doesn't exist otherwise update it. """

    (header,) = HEADER_XPATH(envelope)
    security = SECURITY_XPATH(header)
    if security:
        for timestamp in TIMESTAMP_XPATH(security[0]):
            queue.push_and_mark(timestamp)
        return security[0]
    else:
        nsmap = {
            'wsu': ns.wsuns[1],
            'wsse': ns.wssens[1],
        }
        return _create_element(header, 'wsse:Security', nsmap)