Hello I am thinking about how to change the style of replies to a tree structure. That means the reply to a post will show just below that. like the facebook comments. Is this possible
No, this is not possible.
Discourse is essentially flat and chronological and there is no support for threading apart from one level of direct reply which is a little alike the example in your image. The reply can be viewed directly after the post it replies to but that is in addition to the default position in strict chronological order.
I think that @codinghorror is repeating what he has said elsewhere many times:
There have been a lot of discussions about trees, nesting and threading. Such as this topic:
Which includes specific comments about what you are wanting:
Is it possible to do that by editing the core code?
No, there’s intentionally no capability within Discourse to swap to a threaded model. Topics are linear by design.