Hi Gursimrat ,
Check out this snippet of code.
It checks if the message has parent ,if so assigns parent path to a variable.
If the message is a parent by itself , it assigns the message path to the variable.
<#assign response = rest("/posts/recent").messages/>
<#list response.message as message>
<#if (message.parent.@href?size>0)>
<#assign parentMsgId= message.parent.@href />
<#else>
<#assign isParent = message.parent.@null />
<#if isParent=="true">
<#assign parentMsgId = message.@href />
</#if>
</#if>
${parentMsgId}
<br/>
</#list>
Hope that helps.
Thanks,
Sam