def is_back_tracking(neurite):
def pair(segs):<EOL><INDENT>'''<STR_LIT>'''<EOL>return zip(segs, segs[<NUM_LIT:1>:])<EOL><DEDENT>def coords(node):<EOL><INDENT>'''<STR_LIT>'''<EOL>return node[COLS.XYZ]<EOL><DEDENT>def max_radius(seg):<EOL><INDENT>'''<STR_LIT>'''<EOL>return max(seg[<NUM_LIT:0>][COLS.R], seg[<NUM_LIT:1>][COLS.R])<EOL><DEDENT>def is_not_zero_seg(seg):<EOL><INDENT>'''<STR_LIT>'''<EOL>return not np.allclose(coords(seg[<NUM_LIT:0>]), coords(seg[<NUM_LIT:1>]))<EOL><DEDENT>def is_in_the_same_verse(seg1, seg2):<EOL><INDENT>'''<STR_LIT>'''<EOL>v1 = coords(seg2[<NUM_LIT:1>]) - coords(seg2[<NUM_LIT:0>])<EOL>v2 = coords(seg1[<NUM_LIT:1>]) - coords(seg1[<NUM_LIT:0>])<EOL>return np.dot(v1, v2) >= <NUM_LIT:0><EOL><DEDENT>def is_seg2_within_seg1_radius(dist, seg1, seg2):<EOL><INDENT>'''<STR_LIT>'''<EOL>return dist <= max_radius(seg1) + max_radius(seg2)<EOL><DEDENT>def is_seg1_overlapping_with_seg2(seg1, seg2):<EOL><INDENT>'''<STR_LIT>'''<EOL>s1 = coords(seg2[<NUM_LIT:0>])<EOL>s2 = coords(seg2[<NUM_LIT:1>])<EOL>C = <NUM_LIT:0.5> * (s1 + s2)<EOL>P = coords(seg1[<NUM_LIT:1>])<EOL>CP = P - C<EOL>S1S2 = s2 - s1<EOL>prj = mm.vector_projection(CP, S1S2)<EOL>if not is_seg2_within_seg1_radius(np.linalg.norm(CP - prj), seg1, seg2):<EOL><INDENT>return False<EOL><DEDENT>return np.linalg.norm(prj) < <NUM_LIT> * np.linalg.norm(S1S2)<EOL><DEDENT>def is_inside_cylinder(seg1, seg2):<EOL><INDENT>'''<STR_LIT>'''<EOL>return not is_in_the_same_verse(seg1, seg2) and is_seg1_overlapping_with_seg2(seg1, seg2)<EOL><DEDENT>section_itr = (snode for snode in neurite.iter_sections() if snode.points.shape[<NUM_LIT:0>] > <NUM_LIT:2>)<EOL>for snode in section_itr:<EOL><INDENT>segment_pairs = list(filter(is_not_zero_seg, pair(snode.points)))<EOL>for i, seg1 in enumerate(segment_pairs[<NUM_LIT:1>:]):<EOL><INDENT>for seg2 in segment_pairs[<NUM_LIT:0>: i + <NUM_LIT:1>]:<EOL><INDENT>if is_inside_cylinder(seg1, seg2):<EOL><INDENT>return True<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return False<EOL>
Check if a neurite process backtracks to a previous node. Back-tracking takes place
    when a daughter of a branching process goes back and either overlaps with a previous point, or
    lies inside the cylindrical volume of the latter.

    Args:
        neurite(Neurite): neurite to operate on

    Returns:
        True Under the following scenaria:
            1. A segment endpoint falls back and overlaps with a previous segment's point
            2. The geometry of a segment overlaps with a previous one in the section