Many roads are residential in town; they turn into a track as they go out into the countryside; and eventually become walking paths. In short, they defy a simple classification.
In that case, you should split the segment, and tag the relevant parts as highway=residential, highway=track and highway=path. This issue is not specific to Africa, and splitting the segment is the right answer world-wide.
Additionally, some explicit transport mode restrictions can also be helpful especially if using certain vehicles beyond a certain point is explicitly banned or strongly recommended against by signage. The surface= key has already been mentioned by other posters.