def _relocate_sub_chain(self):
        self._collect_soft_chain()

        # get each file in sub-chain
        head = [n for n in self.nodes if n.id == self.ref]
        if len(head) > 1:
            raise Exception("Error resolving (1)")
        elif len(head) == 0:
            raise Exception("Error resolving (2)")
        else:
            head = head[0]

        sub_chain = []
        while head is not None:
            sub_chain.append(head)
            head = [n for n in self.nodes if n.backref == head.id]
            if len(head) > 1:
                raise Exception("Error resolving (3)")
            elif len(head) == 0:
                head = None
            else:
                head = head[0]

        sub_chain.reverse()

        # find tail of correct chain
        # (as long as it's not the tail of the sub-chain, we should be good)
        tails = []
        for node in self.nodes:
            children = [n for n in self.nodes if n.backref == node.id]
            if len(children) == 0:
                tails.append(node)

        tails = [t for t in tails if t not in sub_chain]
        if len(tails) == 0:
            raise Exception("Error resolving (4)")
        tail = tails[0] # just have to pick one

        # for each file in the sub-chain relocate head of the chain behind
        # correct chain's tail (making it the new tail)
        i = 0
        while len(sub_chain) > 0:
            node = sub_chain.pop()

            # gen new ref
            new_ref = (GenRefCommand(self.context)).gen_ref(i)

            # generate new file-names
            new_up_filename = self._rename_file(filename=node.filename, ref=new_ref)
            new_down_filename = self._rename_file(filename=node.down_filename(), ref=new_ref)

            # move files and edit meta-data (new [back]ref)
            self._relocate_files(
                old_filename=node.filename,
                new_filename=new_up_filename,
                new_ref=new_ref,
                new_backref=tail.id,
                direction='up')
            self._relocate_files(
                old_filename=node.down_filename(),
                new_filename=new_down_filename,
                new_ref=new_ref,
                new_backref=tail.id,
                direction='down')

            # update tail = node
            node.id = new_ref
            node.backref = tail.id
            node.filename = new_up_filename

            tail = node
            i += 1
Given a ref and filename to start from, we need to relocate a
dataset/ETHPy150Open appnexus/schema-tool/schematool/command/resolve.py/ResolveCommand._relocate_sub_chain