<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def putNamedChild(self, res):
 """ putNamedChild takes either an instance of hendrix.contrib.NamedResource or any resource.Resource with a "namespace" attribute as a means of allowing application level control of resource namespacing. if a child is already found at an existing path, resources with paths that are children of those physical paths will be added as children of those resources """

        try:
            EmptyResource = resource.Resource
            namespace = res.namespace
            parts = namespace.strip('/').split('/')

            # initialise parent and children
            parent = self
            children = self.children
            # loop through all of the path parts except for the last one
            for name in parts[:-1]:
                child = children.get(name)
                if not child:
                    # if the child does not exist then create an empty one
                    # and associate it to the parent
                    child = EmptyResource()
                    parent.putChild(name, child)
                # update parent and children for the next iteration
                parent = child
                children = parent.children

            name = parts[-1]  # get the path part that we care about
            if children.get(name):
                self.logger.warn(
                    'A resource already exists at this path. Check '
                    'your resources list to ensure each path is '
                    'unique. The previous resource will be overridden.'
                )
            parent.putChild(name, res)
        except AttributeError:
            # raise an attribute error if the resource `res` doesn't contain
            # the attribute `namespace`
            msg = (
                      '%r improperly configured. additional_resources instances must'
                      ' have a namespace attribute'
                  ) % resource
            raise AttributeError(msg, None, sys.exc_info()[2])