def parse_instance(parser, event, node): #pylint: disable=unused-argument
    """Parse CIM/XML INSTANCE Element and return CIMInstance"""

    classname = _get_required_attribute(node, 'CLASSNAME')

    properties = []
    qualifiers = []

    (next_event, next_node) = six.next(parser)

    if _is_start(next_event, next_node, 'QUALIFIER'):

        qualifiers.append(parse_qualifier(parser, next_event, next_node))

        while 1:

            (next_event, next_node) = six.next(parser)

            if _is_start(next_event, next_node, 'PROPERTY') or \
               _is_start(next_event, next_node, 'PROPERTY.ARRAY') or \
               _is_start(next_event, next_node, 'PROPERTY.REFERENCE') or \
               _is_end(next_event, next_node, 'INSTANCE'):
                break

            if _is_start(next_event, next_node, 'QUALIFIER'):
                qualifiers.append(
                    parse_qualifier(parser, next_event, next_node))
            else:
                raise ParseError('Expecting QUALIFIER')

    while 1:

        if _is_end(next_event, next_node, 'INSTANCE'):
            break

        if _is_start(next_event, next_node, 'PROPERTY'):
            properties.append(parse_property(parser, next_event, next_node))

        elif _is_start(next_event, next_node, 'PROPERTY.ARRAY'):
            properties.append(
                parse_property_array(parser, next_event, next_node))

        elif _is_start(next_event, next_node, 'PROPERTY.REFERENCE'):
            properties.append(
                parse_property_reference(parser, next_event, next_node))
        else:
            raise ParseError(
                'Expecting (PROPERTY | PROPERTY.ARRAY | PROPERTY.REFERENCE)')

        (next_event, next_node) = six.next(parser)

    if not _is_end(next_event, next_node, 'INSTANCE'):
        raise ParseError('Expecting end INSTANCE')

    return CIMInstance(
        classname,
        properties=dict([(x.name, x) for x in properties]),
        qualifiers=dict([(x.name, x) for x in qualifiers]))
Parse CIM/XML INSTANCE Element and return CIMInstance