Grafts a node onto an edge of the Tree, at a point specified by
        length (defaults to middle of edge).

def regraft(self, edge, node, length=None):
        """ Grafts a node onto an edge of the Tree, at a point specified by
        length (defaults to middle of edge). """

        rootcheck(edge, 'SPR regraft is not allowed on the root edge')
        length = length or edge.length / 2.  # Length measured from head to tail
        edge_length_check(length, edge)

        t = edge.tail_node
        h = edge.head_node
        new = t.new_child(edge_length=edge.length - length)
        t.remove_child(h)
        new.add_child(h)
        h.edge.length=length
        new.add_child(node)
        self.tree._dirty = True
        self.tree._tree.encode_bipartitions(suppress_unifurcations=True)