Proper recursive function for polygon overlapping