def get_segment_for_node(cur, segments, node_pkey):
    """ Attempt to determine the segment for the given node.

    Parameters
    ----------
    conn : sqlite3.Connection
        Connection to channels.db
    segments : SegmentWireMap
        Object for determined segment based on wire names.
    node_pkey : int
        Node to determine segment of.  Is primary key into node table.

    Returns
    -------
    segment_pkey : int
        Primary key to segment table of segment for this node.

    """

    cur.execute(
        """
SELECT name FROM wire_in_tile WHERE pkey IN (
    SELECT wire_in_tile_pkey FROM wire WHERE node_pkey = ?
);""", (node_pkey, )
    )

    segment_name = segments.get_segment_for_wires(
        wire for (wire, ) in cur.fetchall()
    )

    cur.execute(
        """
SELECT pkey FROM segment WHERE name = ?
    """, (segment_name, )
    )

    return cur.fetchone()[0]