<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_parent_and_child(self, table_name):
 """ Get the name of the parent table and the child table for a given MagIC table name. Parameters table_name : string of MagIC table name ['specimens', 'samples', 'sites', 'locations'] Returns ------- parent_name : string of parent table name child_name : string of child table name """

        if table_name not in self.ancestry:
            return None, None
        parent_ind = self.ancestry.index(table_name) + 1
        if parent_ind + 1 > len(self.ancestry):
            parent_name = None
        else:
            parent_name = self.ancestry[parent_ind]
        child_ind = self.ancestry.index(table_name) - 1
        if child_ind < 0:
            child_name = None
        else:
            child_name = self.ancestry[child_ind]
        return parent_name, child_name