Often the problem is an autopilot! Once the autopilot is on pilots seem to think it is OK to have their total focus in the aircraft normally looking at maps or writing down details or making calculations.
i was right seat in a SEP with another pilot in the left I had my eyes down reading a Map his attention was elsewhere. I looked up just in time to see an aircraft pass directly over us in the opposite direction. it was a 172 and cannot have been more than 20 feet above us. So Close I could clearly see the tread on his tyres.
The Alarming bit was that the aircraft carried on in a straight line obviously equally unaware of us and obviously equally on autopilot doing the sunday times crossword or something else as he was totally oblivious to us.
the other near miss was in a Seneca descending through cloud IMC when a glider flashed past also in cloud and close enough to be seen in the gloom.
Pace