You can't do Africa-Europe-Africa-Europe as you can only enter/exit a continent once (except Europe, N.America, Asia with exceptions). You could do JNB-LHR-CAI or JNB-LHR-KRT, due to the oddness of OWE geography (both CAI/KRT considered in Europe). You could also do HKG-LHR-ACC-LHR or JFK-LHR-ACC-LHR, these would be considered legal.
You can do an almost-airside transit.. the transit official can escort you through immigration to checkin and back, as you can't get a return boarding pass in London.