returns all the keys in nested a dictionary.
    >>> sorted(serialize_dict_keys({"a": {"b": {"c": 1, "b": 2} } }))
    ['a', 'a.b', 'a.b.b', 'a.b.c']
349104
def serialize_dict_keys(d, prefix=""):
    
    keys = []
    for k, v in d.items():
        fqk = '{}{}'.format(prefix, k)
        keys.append(fqk)
        if isinstance(v, dict):
            keys.extend(serialize_dict_keys(v, prefix="{}.".format(fqk)))

    return keys
914217
def sort_dict_by_key(obj):
    
    sort_func = lambda x: x[0]
    return OrderedDict(sorted(obj.items(), key=sort_func))
574700
def flattened_nested_key_indices(nested_dict):
    
    outer_keys, inner_keys = collect_nested_keys(nested_dict)
    combined_keys = list(sorted(set(outer_keys + inner_keys)))
    return {k: i for (i, k) in enumerate(combined_keys)}
488368
def to_json(self, sort_keys=False):
    
    d = self.to_json_dict()
    return json.dumps(d, sort_keys=sort_keys)
1272674
def get_keys(self, lst):
        
        pk_name = self.get_pk_name()
        return [getattr(item, pk_name) for item in lst]
321325
def ordered_dict_to_dict(d):
    
    ret = {}
    new_d = deepcopy(d)
    for k, v in new_d.items():
        if isinstance(v, OrderedDict):
            v = dict(v)
        if isinstance(v, dict):
            v = ordered_dict_to_dict(v)
        ret[k] = v
    return ret
786990
def _sorted_keys_items(dobj):
    """"""
    keys = sorted(dobj.keys())
    for key in keys:
        yield key, dobj[key]
378090
def keys(self, id=None, search=None):
        
        if self._keys is None:
            self._keys = {}
            self._list_keys()

        if id:
            return [self._keys[key_id] for key_id in self._keys.keys()
                    if id == self._keys[key_id].id]
        elif search:
            return [self._keys[key_id] for key_id in self._keys.keys()
                    if (search in self._keys[key_id].id) or (search in self._keys[key_id].name)]
        else:
            return [self._keys[key_id] for key_id in self._keys.keys()]
734023
def to_dict(self):
        
        out = {}
        for key in self.__dict__.keys():
            if key not in ['left', 'right', 'missing', 'parent']:
                out[key] = self.__dict__[key]
        return out
271414
def values(self):
        
        return dict((k, getattr(self, k)) for k in self._keys)
620838
def nested_dict_to_list(path, dic, exclusion=None):
    
    result = []
    exclusion = ['__self'] if exclusion is None else exclusion

    for key, value in dic.items():

        if not any([exclude in key for exclude in exclusion]):
            if isinstance(value, dict):
                aux = path + key + "/"
                result.extend(nested_dict_to_list(aux, value))
            else:
                if path.endswith("/"):
                    path = path[:-1]

                result.append([path, key, value])

    return result
1082083
def keys(self):
        ''''''
        keys = []
        for key, value in self.map.items():
            if isinstance(value, Shovel):
                keys.extend([key + '.' + k for k in value.keys()])
            else:
                keys.append(key)
        return sorted(keys)
1253137
def sorted_converters_keys(self):
        
        keys = sorted(self.converters.keys(),
                      key=cmp_to_key(tuple_type_compare))
        return {k: self.converters[k] for k in keys}
1188610
def encode_keys(self, keys):
        
        return dict(((k, self.encode(v)) for k, v in six.iteritems(keys) if not
                     is_null(v)))
245603
def get_key_names(self):
        
        names = []
        for (k, _) in self.items():
            names.append(k)
        return names
282146
def _get_keys_defdict(self):
        '''
        '''
        # inspect argspecs
        argspec = inspect.getargspec(self.func)
        keys, defvals = argspec.args, argspec.defaults

        # convert to (list_of_argkeys, dict_of_default_keys)
        if defvals is None:
            return keys, None
        else:
            defvals = list(defvals)
            keys.reverse()
            defvals.reverse()
            defdict = dict(zip(keys, defvals))
            keys.reverse()
            return keys, defdict
49100
def get_dict(dictionary, *keys,**kwargs):
    

    if 'default' in kwargs:
        default = kwargs['default']
    else:
        default = None

    existing = dictionary
    for i in range(0, len(keys)):

        if keys[i] in existing:

            existing = existing[keys[i]]
        else:

            return default
    return existing