def findAppropriateTstep(path, T, stepInPositiveDirection):
    if stepInPositiveDirection:
        Tstep = (1 - T)
    else:
        Tstep = (0 - T)
    if isNear(path.point((T + Tstep)), path.point(T)):
        raise Exception('An impossible Tstep was asked for.')
    maxIts = 200
    its = 0
    while ((not isNear(path.point((T + Tstep)), path.point(T))) and (its < maxIts)):
        Tstep /= 2
        its += 1
    if (its >= maxIts):
        raise Exception("Max iterations reached in bisection to find appropriate Tstep.  This could theoretically be ok if you have a curve with a huge number of segments... just increase the maxIts in findAppropriateTstep if you have a such a curve (but I doubt that's the case - so tell Andy).")
    return (2 * Tstep)
def findAppropriateTstep(path, T, stepInPositiveDirection):
    if stepInPositiveDirection:
        Tstep = (1 - T)
    else:
        Tstep = (0 - T)
    if isNear(path.point((T + Tstep)), path.point(T)):
        raise Exception('An impossible Tstep was asked for.')
    maxIts = 200
    its = 0
    while ((not isNear(path.point((T + Tstep)), path.point(T))) and (its < maxIts)):
        Tstep /= 2
        its += 1
    if (its >= maxIts):
        raise Exception("Max iterations reached in bisection to find appropriate Tstep.  This could theoretically be ok if you have a curve with a huge number of segments... just increase the maxIts in findAppropriateTstep if you have a such a curve (but I doubt that's the case - so tell Andy).")
    return (2 * Tstep)