Let say you want to retrieve a backward chaining of all messages preceding a particular message, assuming the reply_id is nullable, my idea is as follows:
declare @id varchar(255)
set @id = "some message id"
While (@id is not null)
begin
select @id = reply_id from tbl_id where message_id = @id
if @id is not null
end