Change lookup/search code that it returns the match from the last repodata
This is the first part of fixing a longstanding bug. This fixes
the lookup cases and the case where a keyname is provided in the
search/iterator.
We do this by adding a repo_lookup_repodata function that returns the
last repodata that has the specified keyname.
There is also a repo_lookup_repodata_opt function that may return
a repodata that does not contain the keyname instead of NULL. This
is a bit faster if you need to do a lookup anyway.
We also now have a repo_lookup_filelist_repodata that contains all
the logic to deal with filtered filelists.