In software logic, valid paths look more like this:
Each of those arrows is a valid node, from which you derive coordinates, and movement to go from A to B. In theory, the object (circled) may never reach B, because it can walk an infinite path. That's where logic such as A* helps:
That's an algorithm to resolve stuff like this, but it isn't perfect, and implementing it is a complex process.