TNL-549: Fix thread editing.

**Ticket:** [TNL-549](https://openedx.atlassian.net/browse/TNL-549)

@jimabramson , @tymofij, @cahrens  please review.
what guarantee is there that `get_discussion_category_map(course)` will never return something with a circular reference in it?