Selecting longest edge in triangle
Bmesh script

Simply running through and selecting the longest edge of each tri, the result can have any of 1, 2 or all edges of tri selected.

Added code try and avoid this somewhat.

Test script showing how to:


Load current edit mesh into bmesh
Find all triangles in bmesh
Find the longest edge and select it.
Update the edit mesh.


script:

import bpy
import bmesh

context = bpy.context
ob = context.edit_object
me = ob.data
bm = bmesh.from_edit_mesh(me)

# triangles
tris = [f for f in bm.faces if len(f.edges) == 3]
# deselect all edges
for e in bm.edges:
    e.select = False

for f in tris:
    # if an edge already selected continue
    if any(t.select for t in f.edges):
        continue
    # sort by length and selected (if not using continue)
    edges = sorted(f.edges, key=lambda t : [t.calc_length(), t.select])
    # pop the last and select
    edges.pop().select = True

bmesh.update_edit_mesh(me)


Alternativey

Each edge has a link_faces collection. If there are two link faces (not boundary) and the edge is longest of all edges in both faces, then turn into quad. 


Find all edges that have two triangle link faces
For each these edges, (sorted maybe): if it is longest edge of 2 faces and no other edges selected disolve edge to make this face a quad.
otherwise go to next edge.