private static PsiExpression detectExpressionStatement(@NotNull PsiElement element) {
    final PsiElement prevSibling = PsiTreeUtil.skipWhitespacesBackward(element);
    if (prevSibling instanceof PsiStatement) {
      return getExpression((PsiStatement)prevSibling);
    }
    else {
      while(!(element instanceof PsiExpressionStatement) && !(element instanceof PsiReturnStatement)) {
        element = element.getParent();
        if (element == null || element instanceof PsiCodeBlock) return null;
      }
      return getExpression(((PsiStatement)element));
    }
  }
private static PsiExpression detectExpressionStatement(@NotNull PsiElement element)