<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_dependency(self, word_instance, sent_id):
 """ adds an ingoing dependency relation from the projected head of a token to the token itself. """

        # 'head_attr': (projected) head
        head = word_instance.__getattribute__(self.head_attr)
        deprel = word_instance.__getattribute__(self.deprel_attr)
        if head == '0':
            # word represents the sentence root
            source_id = sent_id
        else:
            source_id = '{0}_t{1}'.format(sent_id, head)
            # TODO: fix issue #39, so we don't have to add nodes explicitly
            if source_id not in self.node:
                self.add_node(source_id, layers={self.ns})

        target_id = '{0}_t{1}'.format(sent_id, word_instance.word_id)
        # 'pdeprel': projected dependency relation
        try:
            self.add_edge(source_id, target_id,
                          layers={self.ns, self.ns+':dependency'},
                          relation_type=deprel,
                          label=deprel,
                          edge_type=EdgeTypes.dominance_relation)
        except AssertionError:
            print "source: {0}, target: {1}".format(source_id, target_id)