human
Complete the below
def _resolve_decision_relationships(workflow):

    ''''Requires proper workflow structure.
    Decision must come before a any random ends.
    DecisionEnd nodes are added to the end of the decision DAG.
    Decision DAG ends are inferred by counting the parents of nodes that are node joins.
    A \'related\' link is created to associate the DecisionEnd to the Decision.
    IE:      D
    D   N
    N   N
    N
    equals
    D
    D   N
    N   N
    E
    E
    N
    Performs a depth first search to understand branching.'
    '''
 ... What is a the Python program you requested?
assistant
#Here is the Python program you requested.
    def insert_end(node, decision):
        'Insert    DecisionEnd    between    node    and    node    parents'
        parent_links = node.get_parent_links().exclude(name='default')
        decision_end = decision.get_child_end()
        decision_end_used = False
        for parent_link in parent_links:
            parent = parent_link.parent.get_full_node()
            node_temp = parent
            while (node_temp and (not isinstance(node_temp, Decision))):
                if isinstance(node_temp, Join):
                    node_temp = node_temp.get_parent_fork().get_parent()
                elif isinstance(node_temp, DecisionEnd):
                    node_temp = node_temp.get_parent_decision().get_parent()
                else:
                    node_temp = node_temp.get_parent()
            if ((node_temp.id == decision.id) and (parent.node_type != Decision.node_type)):
                links = Link.objects.filter(parent=parent).exclude(name__in=['related', 'kill', 'error'])
                if (len(links) != 1):
                    raise RuntimeError(_('Cannot    import    workflows    that    have    decision    DAG    leaf    nodes    with    multiple    children    or    no    children.'))
                link = links[0]
                link.child = decision_end
                link.save()
                decision_end_used = True
        if (decision_end_used and (not Link.objects.filter(name='to', parent=decision_end, child=node).exists())):
            link = Link(name='to', parent=decision_end, child=node)
            link.save()
    def decision_helper(decision, subgraphs):
        '\n                Iterates    through    children,    waits    for    ends.\n                When    an    end    is    found,    finish    the    decision.\n                If    the    end    has    more    parents    than    the    decision    has    branches,    bubble    the    end    upwards.\n                '
        if (not Link.objects.filter(parent=decision, name='related').exists()):
            end =...