I could be wrong, but I *think* the same/similar function may already be defined in shared.utils module from autotest.