Getting all nodes between two selected node

I am looking for a way to get all nodes between two selected nodes.See Below image

In the image Node jjh and BCMM is selected.Now i want all nodes between them .i.e fl-11, I should be able …

Have you seen the distances sample?

In particular, you may be interested in the collectAllPaths function.