@staticmethod
    def add_leases(xml, leases):
        
        network_elems = xml.xpath('//network')
        if len(network_elems) > 0:
            network_elem = network_elems[0]
        elif len(leases) > 0:
            network_urn = Xrn(leases[0]['component_id']).get_authority_urn().split(':')[0]
            network_elem = xml.add_element('network', name = network_urn)
        else:
            network_elem = xml
         
        # group the leases by slice and timeslots
        grouped_leases = []

        while leases:
             slice_id = leases[0]['slice_id']
             start_time = leases[0]['start_time']
             duration = leases[0]['duration']
             group = []

             for lease in leases:
                  if slice_id == lease['slice_id'] and start_time == lease['start_time'] and duration == lease['duration']:
                      group.append(lease)

             grouped_leases.append(group)

             for lease1 in group:
                  leases.remove(lease1)

        lease_elems = []
        for lease in grouped_leases:
            #lease_fields = ['lease_id', 'component_id', 'slice_id', 'start_time', 'duration']
            lease_fields = ['slice_id', 'start_time', 'duration']
            lease_elem = network_elem.add_instance('lease', lease[0], lease_fields)
            lease_elems.append(lease_elem)

            # add nodes of this lease
            for node in lease:
                 lease_elem.add_instance('node', node, ['component_id'])



#        lease_elems = []       
#        for lease in leases:
#            lease_fields = ['lease_id', 'component_id', 'slice_id', 'start_time', 'duration']
#            lease_elem = network_elem.add_instance('lease', lease, lease_fields)
#            lease_elems.append(lease_elem)
dataset/ETHPy150Open fp7-ofelia/ocf/vt_manager/src/python/vt_manager/communication/sfa/rspecs/elements/versions/sfav1Lease.py/SFAv1Lease.add_leases/original