Thanks to all for your responses!
Actually, my problem is with the linked nodes DocumentNamePath in the REST response.
I have a linked node which has some child nodes among which few are linked and few are not. For the linked child node, it's showing it's original node's DocumentNamePath which is fine but for the un-linked child nodes also it's showing that linked node DocumentNamePath as it's parent is a linked node.
We want to get the current hierarchy's path as the DocumentNamePath.
Below, I'm trying to explain it with an example.
A --> B (Linked node may be some X --> Y)
|--> C (Linked Node say M --> N)
|--> D (Not linked to any node)
where A is the parent of B and B is the parent of C and D.
Now, the DocumentNamePath for:
X --> Y --> B
M --> N --> C
X --> Y --> B --> D
But for D, we want it as
A --> B --> D in the REST response itself as some other application is consuming the data from there.
I hope, my requirement is clear now.
Please help me to accomplish this task.