extract_pairs function

Extract Pairs from a Path of Indices