President Donald Trump's forceful warnings to North Korea may have been "useful" to pull things back from the brink.