Decide the index for overlapping links

I want to know how can I decide which link remains above if two links overlap.
For example, in the given figure the link from parent to child 1 and child 2 overlaps and when I click on the portion from the parent to child 1, child 2 link is selected always, meaning child 2 link overlaps child 1 link. However, I want the opposite of it to happen, since I have some functionality which appears on hovering over link.
Please note that, I do want to keep the overlapping of links this way, I just want to decide which one remains above the other links in overlapped part.

image

Set or bind the Link’s Part.zOrder property:
https://gojs.net/latest/api/symbols/Part.html#zOrder

It might be easiest to set them all in a “LayoutCompleted” DiagramEvent listener, based on each Link.toNode’s Part.location.