Is there a way to reuse very similar logic (maybe even the same) from: https://github.com/Wikia/app/blob/dev/includes/wikia/nirvana/WikiaResponse.class.php#L474 ?