it so happens I asked the same question a few months ago [1] (unfortunately is it not possible to read the subsequent conversation through the public mailing list archive). As a result, I ended up reporting
rdar://problem/21746078 to make such behavior achievable through public API. I suggest you report a bug for this as well if you want to see this API publicly implemented on Apple’s part – more rdars filed for the same issue usually means more priority for the issue.