Subgame perfect implementation: A necessary and almost sufficient condition