My answer to this Stack Overflow question:
https://stackoverflow.com/a/65451336/2176546
View code snippet