Since i took some time to figure the answer , answering here so someone might get help from this
I found that I can do something like below to achieve the same .
node nextNode = nodeWithValue3.getNextSibling();
nodeWithValue3.getParentNode().insertBefore(newChildNode, nextNode);