def toflatten(pathX, pathY):
    """ Flatten list of paths"""
    flatten=[]
    for i in range(len(pathX)):
        for j in range(len(pathX[i])):
            flatten.append([pathX[i][j], pathY[i][j]])
    return flatten