Fix t-junction in mesh
I came up with the solution below, which seems to work. Generally I just create faces in the holes (the black on the figure above) and finally dissolve degenerate (since the newly introduced faced has the area of zero). 

import bpy
import bmesh
from math import radians, degrees, pi, atan2
from mathutils import Vector, Euler

def isEdgesOverlapping(v, e1, e2):
    if e1 == e2:
        return False
    v0 = v.co
    v1 = None
    v2 = None
    if (e1.verts[0] == v):
        v1 = e1.verts[1].co
    else:
        v1 = e1.verts[0].co
    if (e2.verts[0] == v):
        v2 = e2.verts[1].co
    else:
        v2 = e2.verts[0].co
    dir1 = (v1 - v0).normalized()
    dir2 = (v2 - v0).normalized()
    if dir1.cross(dir2) &lt; 0.00001 and dir1.dot(dir2) &gt; 0.5:
        return True
    return False


def fixTJunctions2(bm): 
    for e in bm.edges:
        e.select = False
    for v in bm.verts:
            for e1 in v.link_edges:
                for e2 in v.link_edges:
                    if isEdgesOverlapping(v, e1, e2):
                        e1.select = True
                        e2.select = True
                        bpy.ops.mesh.edge_face_add()
                        return True
    return False   

def fixTJunctions(obj):
    if bpy.context.mode == 'OBJECT':
        bpy.ops.object.mode_set(mode='EDIT', toggle=True)
    bm = bmesh.from_edit_mesh(obj.data)
    for e in bm.edges:
        e.select = False    
    continueLoop = True 
    count = 0
    while continueLoop:
        bm.faces.ensure_lookup_table()
        bm.edges.ensure_lookup_table()
        bm.verts.ensure_lookup_table()
        continueLoop = fixTJunctions2(bm)
        count = count + 1
    if count &gt; 1:
        bpy.ops.mesh.dissolve_degenerate()

obj = bpy.context.active_object 
fixTJunctions(obj)