This is the original code:
It wasn't tested, so I wrote some tests before start refactoring it:
Once I had the tests in place, I separated the responsibility of converting strings into dates from the traversing of the object:
and extracted it to another factory:
that I could directly test:
By separating the traversing and conversion responsibilities and by using underscore.js, I managed to get to a much more readable version of the code.