def update(self, E=None, **F):
        """
        D.update(E, **F) -> None.  Update D from E and F: for k in E: D[k]
                = E[k]
        (if E has keys else: for (k, v) in E: D[k] = v) then: for k in
                F: D[k] = F[k]

        :type E: dict
        :type F: dict
        """
        _AutoDict = self.__class__

        def update_or_set(key, value):
            if isinstance(value, dict):
                self[key] = _AutoDict(obj=value, _root=self._root, _parent=self, _key=key)
            else:
                self[key] = value

        with self.lock() as lock_owner:
            # update E
            if hasattr(E, 'keys') and callable(E.keys):
                for k in E:
                    update_or_set(k, E[k])
            else:
                for k, v in E:
                    update_or_set(k, v)

            # update F
            for k in F:
                update_or_set(k, F[k])

            # save if original caller.
            if lock_owner:
                self._root.save()