That is not pathfinding, is just "border check".
Add raycasts to the sides pointing down, if going to the left, check the left one, if going to the right, check the right one.
If the raycast gives a "false" collision with the floor, is because there is no floor and the body need to turn to the other side.
The platformer demo uses that simple approach for the enemies.