'Connect dependencies to existing edges in the frontier.
``deps`` are to be inserted at position i in the
frontier. This routine determines whether other open edges
should be merged with <deps> (if there are other open edges
pointing to the same place) or whether they should just be
inserted as a completely new open edge.
Open edges that are not fully expanded (i.e. those that point
at multiple places) are left intact.
Parameters:
label    -- optional debug label for the connection.
Returns: True if the deps were connected to another edge
(i.e. the frontier did not grow) and False if the deps were
NOT already in the frontier (i.e. they were inserted and the
frontier grew).'

def _connect_deps(self, i, deps, label=None):

    if ((len(deps) == 1) and (deps in self._frontier)):
        j = self._frontier.index(deps)
        if (i < j):
            self._frontier.pop(j)
            self._frontier.insert(i, deps)
            return self._connect_deps(j, deps, label)
        collapse = True
        if (self._prev_state == EXPAND_RIGHT):
            self._back_edge_line([], j, (i + 1), True, ((label + '-1.5    ') + str(((i + 1), j))))
            collapse = False
        else:
            if ((self._prev_state == NODE) and (self._prev_index < i)):
                i += 1
            if ((i - j) > 1):
                self._back_edge_line([], j, i, True, ((label + '-1    ') + str((i, j))))
                collapse = False
        self._back_edge_line([j], (-1), (-1), collapse, ((label + '-2    ') + str((i, j))))
        return True
    elif deps:
        self._frontier.insert(i, deps)
        return False
