you can lose this conditional and the next line if you replace the ip_index assignment to ip_index = _make_group_index(vpnrr_index.get(asn, []), 'address')
you can lose this conditional and the next line if you replace the ip_index assignment to ip_index = _make_group_index(vpnrr_index.get(asn, []), 'address')