The code was a bit hard to follow. Use clear/explicity variable names and comment a bit more on what is going on. Also fold the double list iteration into a single one Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4694>