<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_child(self, child):
 """Add a child FSEntry to this FSEntry. Only FSEntrys with a type of 'directory' can have children. This does not detect cyclic parent/child relationships, but that will cause problems. :param metsrw.fsentry.FSEntry child: FSEntry to add as a child :return: The newly added child :raises ValueError: If this FSEntry cannot have children. :raises ValueError: If the child and the parent are the same """

        if self.type.lower() != "directory":
            raise ValueError("Only directory objects can have children")
        if child is self:
            raise ValueError("Cannot be a child of itself!")
        if child not in self._children:
            self._children.append(child)
        child.parent = self
        return child