A generic function like this should be in `corehq.util` or something. We used to just put everything in `dimagi.utils`, but that's gotten to be super annoying.