Fixed search problem ('dict' object has no attribute 'CategoryId') (2/2), more pythonesque way