@FluffyDeveloper

I suspect there's something else going on here, or your comments data is far different than I'm supposing.

Your flatten method works just fine for me with a tree of 600 comments. In fact, it works fine with 600,000 comments (recurs. lim. 1000)

Example test script:
https://pastebin.com/6Mdvu2WL

Without seeing your other code, I don't know what the issue you're running into. At a wild guess, is it possible your graph is not acyclic?

#recursion #python #graph #cyclic #acyclic

#!/usr/bin/env pythonfrom datetime import datetime, timedelta, timezonefro - Pastebin.com

Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

Pastebin