@felix ah yes it is. I also present comments as a tree and I wanted to be able to select a subtree from any level, so I did a very cursed thing with "reply keys": https://github.com/grishka/Smithereen/blob/master/src/main/java/smithereen/data/Post.java#L73 It's an array of all parent post IDs serialized as int32s that I store in a database column. There's an index on it and I can select all posts with a certain prefix using LIKE BINARY.
@grishka i'm not sure what the code does, but storing the parent post for each comment seems totally normal, we are doing the same thing. though @dessalines wants to change that, apparently there is support in postgres for storing tree relations directly or something like that (but quite complicated).