def __deepcopy__(self, memo):
        """ Overrides deepcopy for HasTraits because otherwise we lose instance
        traits when we copy. :(
        """
        id_self = id(self)
        if id_self in memo:
            return memo[id_self]

        # Make sure HasTraits is performing all deepcopies. We need this
        # in order for our sub-components and objects to get deep-copied.
        memo['traits_copy_mode'] = "deep"

        saved_p = self._parent
        saved_c = self._cached_traits_
        saved_s = self._setcache
        saved_g = self._getcache
        self._parent = None
        self._cached_traits_ = None
        self._getcache = {}
        self._setcache = {}
        try:
            result = super(Container, self).__deepcopy__(memo)
        finally:
            self._parent = saved_p
            self._cached_traits_ = saved_c
            self._getcache = saved_g
            self._setcache = saved_s

        # Instance traits are not created properly by deepcopy, so we need
        # to manually recreate them. Note, self._added_traits is the most
        # accurate listing of them. Self._instance_traits includes some
        # extra stuff.
        olditraits = self._instance_traits()
        for name, trait in olditraits.items():
            if trait.type is not 'event' and name in self._added_traits:
                if isinstance(trait.trait_type, VarTree):
                    if name not in result._added_traits:
                        result.add_trait(name, _clone_trait(trait))
                else:
                    result.add_trait(name, _clone_trait(trait))
                if self.__dict__ in name:  # Not true with VarTree
                    result.__dict__[name] = copy.deepcopy(self.__dict__[name])

        return result
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.main/src/openmdao/main/container.py/Container.__deepcopy__/swapped operands of `in`