def _connect_seg_to_poly(poly_verts, seg, tol):
    """Connect a LineSegment to a list of polyline vertices.

    If successful, a Point will be appended to the poly_verts list and True
    will be returned. If not successful, the poly_verts list will remain unchanged
    and False will be returned.

    Args:
        poly_verts: An ordered list of Points to which the segment should
            be connected.
        seg: A LineSegment to connect to the poly_verts.
        tol: The tolerance to be used for connecting the line.
    """
    p1, p2 = seg.p1, seg.p2
    if poly_verts[-1].is_equivalent(p1, tol):
        poly_verts.append(p2)
        return True
    elif poly_verts[0].is_equivalent(p2, tol):
        poly_verts.insert(0, p1)
        return True
    elif poly_verts[-1].is_equivalent(p2, tol):
        poly_verts.append(p1)
        return True
    elif poly_verts[0].is_equivalent(p1, tol):
        poly_verts.insert(0, p2)
        return True
    return False
