Library - Zill
Here is a conceptual Python implementation of the logic. This function would process raw search results to group them cleanly.
Assume the library is stored as files in a known directory, e.g., /lib/zill/ or loaded via an import system. zill library
pip install zill-lib