'Relabels the alias values of any children. \'change_map\' is a dictionary
mapping old (current) alias values to the new values.'

def relabel_aliases(self, change_map, node=None):

    if (not node):
        node = self
    for (pos, child) in enumerate(node.children):
        if hasattr(child, 'relabel_aliases'):
            child.relabel_aliases(change_map)
        elif isinstance(child, tree.Node):
            self.relabel_aliases(change_map, child)
        elif isinstance(child, (list, tuple)):
            if isinstance(child[0], (list, tuple)):
                elt = list(child[0])
                if (elt[0] in change_map):
                    elt[0] = change_map[elt[0]]
                    node.children[pos] = ((tuple(elt),) + child[1:])
            else:
                child[0].relabel_aliases(change_map)
            if hasattr(child[3], 'relabel_aliases'):
                child[3].relabel_aliases(change_map)
