Alright, in context of the comments to the question, i have created a pre-liminary logic to check if discussion item is a Reply to Reply.
SharePoint API provides
SPUtility.CreateNewDiscussionReply static method to create a reply programmatically. But when it comes to get the parent of a discussion item I couldn't find any API method, neither was I able to find any column which had item ID of (Threading) Parent, though there is a column named ParentReplyId which will always return the parent discussion item ID - confusing as it sounds.
While rendering replies in a threading view, SharePoint makes use of hidden columns one of which is Threading (there are more, can't remember their exact names right now but they have the same values). If you try to peek in the value in this column for a discussion item, it goes as:
#Value in Threading Column for Parent Discussion Item - (ID: 1) - 46 Characters
#Value in Threading Column for All Root Discussion Item Replies - (ID: 2) - 56 Characters
#Value in Threading Column for a Reply to Reply Item - (ID: 3) - 66 Characters
If you look closely, each reply has a Threading column value appended with 10 chars to the Threading column value of its parent.
So considering the above scenario:
Reply A Threading Column has
00000306CE appended to
0x01D20ADFBC6516050BCBEA944043A300C5156D3774F0 which was the Threading column value for Root Discussion item - (ID: 1).
Here I believe that length of the threading value remains constant i.e. 46 for each Root discussion items and with each reply some 10 randomly characters are appended to the threading column value of its parent's Threading column.
Why the length of all root discussion items Threading value is going to be 46 is answered by the fact how SharePoint structures it. For example
Message (Item) CT ID - Item GUID - Some 10 randomly generated chars
4-32-10 = 46
This might look a little confusing but it will make sense if you think. I have managed to pull a puesdo logic to get the parent item of reply to reply item.
If($ReplyB["Threading"].Length -ge 66)
#Current Item is a Reply to Reply
#Query for the Reply Parent in discussion list where Threading Column value is current items Threading column value - 10
#Here you could build a CAML query and find items whose Threading Value is:
$ReplyB["Threading"].Remove($ReplyB["Threading"].Length - 10)
Disclaimer: This code is not tested but i believe it to work. I hope somebody could come and correct me, may be with a better/efficient solution. But for now i think this should work for anybody stuck in the same issue.