Allocated StereotypeWrapper in 2022x

I want to simplify some of my Macros and scripts.

We are working in groovy and I often find myself wanting to make better use of the SysML Profile StereotypeWrapper capabilities, but so far I have had no luck in doing so. 

I recently had to find all the elements that a given element was allocated to. I ended up creating a function to get all the directed relationships of source on the given element, finding all those with the Allocate stereotype and returning that list. However the Profile Allocated StereotypeWrapper appears to have a method to do this directly (getAllocatedTo(element). However I had no luck in getting this to actually work. (Only getting empty Lists when I tried)

Can someone show me some sample code to get this to work? It seems like these Wrappers could save a lot of time, but I am doing something wrong here.