def ensure_security_header(envelope, queue):
(header,) = HEADER_XPATH(envelope)<EOL>security = SECURITY_XPATH(header)<EOL>if security:<EOL><INDENT>for timestamp in TIMESTAMP_XPATH(security[<NUM_LIT:0>]):<EOL><INDENT>queue.push_and_mark(timestamp)<EOL><DEDENT>return security[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>nsmap = {<EOL>'<STR_LIT>': ns.wsuns[<NUM_LIT:1>],<EOL>'<STR_LIT>': ns.wssens[<NUM_LIT:1>],<EOL>}<EOL>return _create_element(header, '<STR_LIT>', nsmap)<EOL><DEDENT>
Insert a security XML node if it doesn't exist otherwise update it.