Ensure we take the object lock while accessing `GstElement.sinkpads`. Use an iterator when the code isn't simple to avoid deadlock. When we find the best pad, take a reference so a concurrent pad release doesn't destroy the pad before we're done with it. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1553>