ResourceFunction[
 "MultiwaySystem"][{"A" -> "AB", "B" -> "BA"}, "ABA", 2, "BranchPairsList"]