def get_pins(conn, site_type, site_pin):
    """ Returns a set of the pin graph_nodes related to the input site type and pin names."""

    c = conn.cursor()
    c.execute(
        """
WITH pins(wire_in_tile_pkey) AS (
  SELECT wire_in_tile.pkey FROM wire_in_tile
  INNER JOIN site_pin ON site_pin.pkey = wire_in_tile.site_pin_pkey
  INNER JOIN site_type ON site_pin.site_type_pkey = site_type.pkey
  WHERE
    site_type.name == ?
  AND
    site_pin.name == ?
)
SELECT graph_node.pkey FROM graph_node
INNER JOIN wire ON graph_node.node_pkey = wire.node_pkey
WHERE
  wire.wire_in_tile_pkey IN (SELECT wire_in_tile_pkey FROM pins);
    """, (
            site_type,
            site_pin,
        )
    )

    return set(graph_node_pkey for (graph_node_pkey, ) in c.fetchall())