How do we know whether an workitem has links programmatically
One answer
Please see https://rsjazz.wordpress.com/2012/09/19/the-rtc-workitem-link-api-linking-workitems-to-other-elements/ especially Accessing References.
Comments
You need to write a work item save advisor. The closest example I have published is https://rsjazz.wordpress.com/2014/05/26/only-owner-can-close-workitem-advisor/
Also see the extensions workshop referenced in the post to detect a state change.
You also want to look at the server link API: https://rsjazz.wordpress.com/2012/09/20/the-rtc-workitem-server-link-api-linking-to-work-items-and-other-elements/
Basically you want to check if there are children similar to https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/ and then decide to stop the save.