On another note, you can reuse one of the utils methods: https://github.com/forkcms/forkcms/blob/master/backend/core/js/utils.js#L229