Please use the built-in org-collect-keywords instead.
Thanks for the pointer, I changed the function in the attached patch.
This is a user-facing change and should be documented in etc/ORG-NEWS file.
Not sure how you normally go about updates to submitted patches. For this time, I just updated the patch by amending the commit of the previous patch I sent. Please let me know another approach is preferable going forward.
Thanks,
Duy