'Parse the XML element and return a SecurityGroup object.
:rtype:     :class:`EC2SecurityGroup`'

def _to_security_group_rule(self, element):

    rule = {}
    rule['protocol'] = findtext(element=element, xpath='ipProtocol', namespace=NAMESPACE)
    rule['from_port'] = findtext(element=element, xpath='fromPort', namespace=NAMESPACE)
    rule['to_port'] = findtext(element=element, xpath='toPort', namespace=NAMESPACE)
    elements = element.findall(fixxpath(xpath='groups/item', namespace=NAMESPACE))
    rule['group_pairs'] = []
    for element in elements:
        item = {'user_id': findtext(element=element, xpath='userId', namespace=NAMESPACE), 'group_id': findtext(element=element, xpath='groupId', namespace=NAMESPACE), 'group_name': findtext(element=element, xpath='groupName', namespace=NAMESPACE)}
        rule['group_pairs'].append(item)
    elements = element.findall(fixxpath(xpath='ipRanges/item', namespace=NAMESPACE))
    rule['cidr_ips'] = [findtext(element=element, xpath='cidrIp', namespace=NAMESPACE) for element in elements]
    return rule
