refactor: filter_dynamic_link_doctypes API
refactor: filter_dynamic_link_doctypes API

* Added typing, better variable naming
* Remove unnecessary re-iterations
* Optimize queries and membership processing

frappe/frappe,frappe/frappe,yashodhank/frappe,StrellaGroup/frappe,StrellaGroup/frappe,yashodhank/frappe,frappe/frappe,yashodhank/frappe,StrellaGroup/frappe,yashodhank/frappe