@ilwdchar_compat<EOL>def get_ligolw_element(xmldoc):
from ligo.lw.ligolw import LIGO_LW<EOL>try:<EOL><INDENT>from glue.ligolw.ligolw import LIGO_LW as LIGO_LW2<EOL><DEDENT>except ImportError:<EOL><INDENT>ligolw_types = (LIGO_LW,)<EOL><DEDENT>else:<EOL><INDENT>ligolw_types = (LIGO_LW, LIGO_LW2)<EOL><DEDENT>if isinstance(xmldoc, ligolw_types):<EOL><INDENT>return xmldoc<EOL><DEDENT>else:<EOL><INDENT>for node in xmldoc.childNodes:<EOL><INDENT>if isinstance(node, ligolw_types):<EOL><INDENT>return node<EOL><DEDENT><DEDENT><DEDENT>raise ValueError("<STR_LIT>")<EOL>
Find an existing <LIGO_LW> element in this XML Document