title: SQL: Compare parental hierarchies and exclude if duplicated
body: <p>I want to exclude duplicates from my data, unless the duplicate is part of a new grouping /series.</p>
  
  <pre><code>CREATE TABLE #MYTEMPTABLE
  (CHILD VARCHAR(2), PARENT VARCHAR(2),YEAR INT)
  INSERT INTO #MYTEMPTABLE (CHILD, PARENT,YEAR)
  VALUES 
  ('1B','1A',2014),
  ('1A','1A',2014),
  ('2B','2A',2014),
  ('2A','2A',2014),
  ('3A','3A',2014),
  ('3B','3A',2014),
   also would have ('3B','3B',2014)
  ('3C','3B',2014),
  ('4A','4A',2014),
  ('4B','4A',2014),
   and ('4B','4B',2014)
  ('4C','4B',2014)
  
  CREATE TABLE #MYTEMPTABLE2
  (CHILD VARCHAR(2), PARENT VARCHAR(2),YEAR INT)
  
  INSERT INTO #MYTEMPTABLE2  (CHILD, PARENT,YEAR)
  VALUES 
  ('1A','1A',2015),
  ('1C', '1A',2015),
  ('2B','2A',2015),
  ('2A', '2A',2015),
  ('3A','3A',2015),
  ('3B','3A',2015),
    ('3B','3B',2014)
  ('3C','3B',2015),
  ('4A','4A',2015),
  ('4B','4A',2015),
    ('4B','4B',2015),
  ('4D','4B',2015)
  </code></pre>
  
  <p>What I want now:<br>
        1B, 1A<br>
        1A, 1A<br>
        2B, 2A<br>
        2A, 2A<br>
        3A, 3A<br>
        3B, 3A<br>
        3B, 3B<br>
        3C, 3B<br>
        4A ,4A<br>
        4B, 4A<br>
        4B, 4B<br>
        4C, 4B<br>
        1A, 1A<br>
        1C, 1A<br>
        4B, 4B<br>
        4D, 4B  </p>