Using `get_content_titles` for this seems a bit risky. Since the actual question you're trying to answer is whether there are any grandchildren of the course, it seems like doing that directly might be better, by just iterating over `course.get_children`, and recursing on that to the depth you need.

Also, catching `UndefinedContext` here seems really suspect. Why is that particular exception being raised? And when you catch it, why does that mean that there's content?