def _compute_segseg_intersection(segment1, segment2):
    """Algorithm to compute a segment to segment intersection.
    Based on this article:
        https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection

    :param segment1: first segment (defined by two endpoints)
    :type segment1: list
    :param segment2: second segment (defined by two endpoints)
    :type segment2: list
    :return: intersection point (p_x, p_y), if it exists
    :rtype: tuple or None
    """
    (x1, y1), (x2, y2) = segment1
    (x3, y3), (x4, y4) = segment2

    # Check for parallel lines
    denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)

    if denominator == 0:
        return None

    t = ((x1 - x3) * (y3 - y4) - (y1 - y3) * (x3 - x4)) / denominator
    u = -((x1 - x2) * (y1 - y3) - (y1 - y2) * (x1 - x3)) / denominator

    # Check for intersections outside of the segments
    if (t < 0 or t > 1) or (u < 0 or u > 1):
        return None

    p_x = x1 + t * (x2 - x1)
    p_y = y1 + t * (y2 - y1)
    return (p_x, p_y)