element: Add helper to get dependencies for a list of elements in a scope This allows us to remove the checks about 'visited' sets that were sometimes used or not and allows us to open this for plugins that might want this functionality