'Restore the state of this parameter and its children from a structure generated using saveState()
If recursive is True, then attempt to restore the state of child parameters as well.
If addChildren is True, then any children which are referenced in the state object will be
created if they do not already exist.
If removeChildren is True, then any children which are not referenced in the state object will
be removed.
If blockSignals is True, no signals will be emitted until the tree has been completely restored.
This prevents signal handlers from responding to a partially-rebuilt network.'

def restoreState(self, state, recursive=True, addChildren=True, removeChildren=True, blockSignals=True):

    state = state.copy()
    childState = state.pop('children', [])
    if isinstance(childState, dict):
        cs = []
        for (k, v) in childState.items():
            cs.append(v.copy())
            cs[(-1)].setdefault('name', k)
        childState = cs
    if blockSignals:
        self.blockTreeChangeSignal()
    try:
        self.setOpts(**state)
        if (not recursive):
            return
        ptr = 0
        foundChilds = set()
        for ch in childState:
            name = ch['name']
            gotChild = False
            for (i, ch2) in enumerate(self.childs[ptr:]):
                if (ch2.name() != name):
                    continue
                gotChild = True
                if (i != 0):
                    self.insertChild(ptr, ch2)
                ch2.restoreState(ch, recursive=recursive, addChildren=addChildren, removeChildren=removeChildren)
                foundChilds.add(ch2)
                break
            if (not gotChild):
                if (not addChildren):
                    continue
                ch2 = Parameter.create(**ch)
                self.insertChild(ptr, ch2)
                foundChilds.add(ch2)
            ptr += 1
        if removeChildren:
            for ch in self.childs[:]:
                if (ch not in foundChilds):
                    self.removeChild(ch)
    finally:
        if blockSignals:
            self.unblockTreeChangeSignal()
