Find closest element and connect into


My goal is to find the closest element (pipe) and connect another element into it. I’m able to find the closest point of the pipe geometry, but can’t figure it out how to retrieve an actual element to be able to use Element.ConnectInto node. Does anyone have any good tips of how to make this more simple? Thanks.

Take a look here and here where it’s well explained how to retrieve the closest element\point