Hi - there is no such law that I am aware of - you may be referring to a 2003 Judgment of Vogel v Crewe which has been summarised as follows:
Vogel vs. Crewe and another (2003(4) SA 509(T) - Vogel believed that Crewe’s trees - which were growing within two metres of the boundary - were causing various problems on his (Vogel’s) property: the leaves were blocking his gutters and swimming pool, the trees were affecting his sewage system and damaging his parking area, and they were also damaging the concrete wall between the properties.
“Based on a test of objective reasonableness - which included considering the trouble the trees were causing for the neighbour versus the benefits of protecting them for the visual pleasure they provide, for their shade, and even for the oxygen they produce - the judge found that Crewe couldn’t be forced to remove the trees,” said Cor.
He said, too, that the case was significant for a number of reasons: it took the environment into consideration (“And given the problems of climate change, everyone ought to think twice before cutting down a tree”); and it addressed the question of what is and isn’t reasonable.
“The judge made it clear that you have to make allowances for the fact that properties are getting smaller - and in Vogel and Crewe’s case, the pleasure that the tree provided would therefore necessarily require a certain amount of effort and tolerance,” said Cor.
“Damage of the kind that Vogel was claiming can be prevented by normal maintenance - by cleaning the gutters on a regular basis, for example.”
Ill look for other case law but I'm not aware of a more recent judgment compelling the removal of trees within 2 metres of a boundary wall or fence?