private static ExpressionTree stripParensAndCasts(ExpressionTree expr) {
    boolean someChange = true;
    while (someChange) {
      someChange = false;
      if (expr.getKind().equals(PARENTHESIZED)) {
        expr = ((ParenthesizedTree) expr).getExpression();
        someChange = true;
      }
      if (expr.getKind().equals(TYPE_CAST)) {
        expr = ((TypeCastTree) expr).getExpression();
        someChange = true;
      }
    }
    return expr;
  }
private static ExpressionTree stripParensAndCasts ( ExpressionTree expr ) { boolean someChange = true ; while ( someChange ) { someChange = false ; if ( expr . getKind ( ) . equals ( PARENTHESIZED ) ) { expr = ( ( ParenthesizedTree ) expr ) . getExpression ( ) ; someChange = true ; } if ( expr . getKind ( ) . equals ( TYPE_CAST ) ) { expr = ( ( TypeCastTree ) expr ) . getExpression ( ) ; someChange = true ; } } return expr ; }
strip out enclosing parentheses and type casts.

@param expr
@return