code: def deduplicate_tree(r_list, tgt_vocab):
      q = [Tree.convert_to_tree(r_list, 0, len(r_list), tgt_vocab)]
      head = 0
      while head < len(q):
          t = q[head]
          if len(t.children) > 0:
              k = {}
              for i in range(len(t.children)):
                  if isinstance(t.children[i], Tree):
                      k[t.children[i].to_string().strip()] = i
                  else:
                      k[str(t.children[i]).strip()] = i
              cnt_deleted = 0
              for index in list(range(len(t.children))):
                  if index not in ([item[1] for item in k.items()]):
                      t.children.pop(index - cnt_deleted)
                      t.num_children = t.num_children - 1
                      cnt_deleted += 1
  
          for i in range(len(t.children)):
              if isinstance(t.children[i], Tree):
                  q.append(t.children[i])
          head = head + 1
      return q[0].to_list(tgt_vocab)
  
imports: from operator import itemgetter
  import numpy
label_desc: Use image node_id 8 for calling the Tree obj's underlying member method code with example usage: obj.deduplicate_tree(r_list, tgt_vocab) and returns: q