def insert_or_append(parent, node, next_sibling):
<EOL>if next_sibling:<EOL><INDENT>parent.insertBefore(node, next_sibling)<EOL><DEDENT>else:<EOL><INDENT>parent.appendChild(node)<EOL><DEDENT>
Insert the node before next_sibling. If next_sibling is None, append the node last instead.