To hit the nail on the head
To identify something exactly; to arrive at exactly the right solution/analysis.
e.g. I had a recurring problem with my car engine and had it back at the garage several times until the engineer identified a rare problem with the clutch; he hit the nail on the head and the car has run trouble-free ever since.
No one knows the exact origin of this phrase. It appears in The Book of Margery Kempe, circa 1438. This was an account of the life of religious visionary Margery Kempe and is considered to be the earliest surviving autobiography written in English:
"Yyf I here any mor thes materys rehersyd, I xal so smytyn ye nayl on ye hed that it schal schamyn alle hyr mayntenowrys."
In modernised English, that reads as:
"If I hear any more these matters repeated, I shall so smite the nail on the head that it shall shame all her supporters."
Kempe's meaning isn't entirely clear. Some have interpreted her 'hit the nail on the head' as 'speak severely'.
The current 'get to the heart of the matter' meaning is unambiguous in a later reference; William Cuningham’s The Cosmographical Glass, 1559:
“You hit the naile on the head”