Find if a point A and point B belongs to the path C->D