code: function(element1, element2) {
  
          while (true) {
  
              if(element1.tagName !== element2.tagName) {
                  return false;
              }
              if(element1 === element2) {
                  return true;
              }
  
              // stop at body tag
              if (element1 === undefined || element1.tagName === 'body'
                  || element1.tagName === 'BODY') {
                  return false;
              }
              if (element2 === undefined || element2.tagName === 'body'
                  || element2.tagName === 'BODY') {
                  return false;
              }
  
              element1 = element1.parentNode;
              element2 = element2.parentNode;
          }
      }
docs: Compares whether two elements are similar. Similar elements should
  have a common parrent and all parent elements should be the same type.
  @param element1
  @param element2