public static boolean isSameElementType(ASTNode node1,ASTNode node2){
  return node1 != null && node2 != null && node1.getElementType() == node1.getElementType();
}

public static boolean isSameElementType ( ASTNode node1 , ASTNode node2 ) { return node1 != null && node2 != null && node1 . getElementType ( ) == node1 . getElementType ( ) ; }
checks if ielementtype of both nodes are the same . returns false if either are null .
