You can reduce code duplication by doing something like:
```python
if lower_only:
    candidate_key = "lower_course_id"
else:
    candidate_key = "course_id"

published_locator = BlockUsageLocator(
    candidate[candidate_key], branch=candidate['prod_branch'], block_id=block_id
)
draft_locator = BlockUsageLocator(
    candidate[candidate_key], branch=candidate['draft_branch'], block_id=block_id
)
```