'Return a structure representing the entire state of the parameter tree.
The tree state may be restored from this structure using restoreState().
If *filter* is set to \'user\', then only user-settable data will be included in the
returned state.'

def saveState(self, filter=None):

    if (filter is None):
        state = self.opts.copy()
        if (state['type'] is None):
            global PARAM_NAMES
            state['type'] = PARAM_NAMES.get(type(self), None)
    elif (filter == 'user'):
        state = {'value': self.value()}
    else:
        raise ValueError(("Unrecognized    filter    argument:    '%s'" % filter))
    ch = OrderedDict([(ch.name(), ch.saveState(filter=filter)) for ch in self])
    if (len(ch) > 0):
        state['children'] = ch
    return state
