def _prep_for_add(self, name, obj):
        """Check for illegal adds and update the new child
        object in preparation for insertion into self.
        """
        if '.' in name:
            self.raise_exception(
                'add does not allow dotted path names like %s' %
                name, ValueError)
        elif not is_legal_name(name):
            self.raise_exception("'%s' is a reserved or invalid name" % name,
                                 NameError)

        removed = False
        if has_interface(obj, IContainer):
            # if an old child with that name exists, remove it
            if self.contains(name) and getattr(self, name):
                self.remove(name)
                removed = True

        if has_interface(obj, IContainer):
            self._check_recursion(obj)
            if IContainerProxy.providedBy(obj):
                obj.parent = self._get_proxy(obj)
            else:
                obj.parent = self
            obj.name = name

            self._add_after_parent_set(name, obj)

            # if this object is already installed in a hierarchy, then go
            # ahead and tell the obj (which will in turn tell all of its
            # children) that its scope tree back to the root is defined.
            if self._call_cpath_updated is False:
                obj.cpath_updated()

        return removed
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.main/src/openmdao/main/container.py/Container._prep_for_add/original