(bug) Fix bug with getFullMessageTree function and add feature to db