code: def comment_thread(context, parent):
      
      if "all_comments" not in context:
          comments = defaultdict(list)
          if "request" in context and context["request"].user.is_staff:
              comments_queryset = parent.comments.all()
          else:
              comments_queryset = parent.comments.visible()
          for comment in comments_queryset.select_related("user"):
              comments[comment.replied_to_id].append(comment)
          context["all_comments"] = comments
      parent_id = parent.id if isinstance(parent, ThreadedComment) else None
      try:
          replied_to = int(context["request"].POST["replied_to"])
      except KeyError:
          replied_to = 0
      context.update({
          "comments_for_thread": context["all_comments"].get(parent_id, []),
          "no_comments": parent_id is None and not context["all_comments"],
          "replied_to": replied_to,
      })
      return context
docs: Return a list of child comments for the given parent, storing all
      comments in a dict in the context when first called, using parents
      as keys for retrieval on subsequent recursive calls from the
      comments template.