'Cut off the ancestor<-head vertex from this path, retaining
the head node
@param head: the head node
@param ancestor: the ancestor node'

def cut(self, head, ancestor=None):

    if (ancestor is not None):
        sequence = [str(head), str(ancestor)]
        pos = self.find(sequence)
        if (pos > 0):
            self.nodes = self.nodes[:pos]
    elif (str(head) == self.first()):
        self.nodes = []
    return self
