def isSameNode(node1, node2):
    """Compare two nodes, returning true if they are the same.

    Use the DOM lvl 3 Node.isSameNode method if available, otherwise use a
    simple 'is' test.

    """

    if hasattr(node1, 'isSameNode'):
        return node1.isSameNode(node2)
    else:
        return node1 is node2