Novak Djokovic believes the biggest setback of his career to date helped spur his return to the top of men's tennis.