You look for a published fare between the origin and the destination. The intermediate points are irrelevant when looking for the fare. Once you've found the fare, you look at its routing rules to see if the fare can be used for the exact itinerary desired, including the intermediate points. This is a complicated task that's hard to explain. You need to know how fares work to do it correctly.