For this block of code, this might be a bit better:

```python
from SoftLayer.utils import lookup

...

        price_id = None
        items = package.getItems(id=0, mask='mask[itemCategory]')
        for item in items:
            category_code = lookup(item, 'itemCategory', 'categoryCode')
            if all(category_code == category,
                   item['capacity'] == str(quantity),
                   version == 4 or (version == 6 and
                                    desc in item['description'])):
                price_id = item['prices'][0]['id']
                break
```