def METHOD_NAME(self, path, A, B):
    path = deepcopy(path)
    newpath = self._findSubpath(path, A, B)
    if newpath is None:
        path.invert()
        newpath = self._findSubpath(path, A, B)
    return newpath