Given a merkle tree and a transaction that is in that tree, to find the path from the root to that transaction, first hash the transaction. Then find the leaf node in the merkle tree with that hash. Add that node to a list. Take the parent of that node. Add that node to the list. Take it's parent, add it to the list. So on and so forth until you reach the merkle root (which can be identified as the node with no parent). The list of nodes is the path.
If you also need the other node each node was hashed with so you can construct a merkle proof, for every node, when you go to it's parent node, see which side the node you came from was on and record it. And then record the hash of the node on the other side and the side it was on.