code: private static Node asDetachedExpression(Node expr) {
      switch (expr.getToken()) {
        case SPREAD:
          expr = IR.arraylit(expr.detach()).srcref(expr);
          break;
        default:
          break;
      }
  
      if (expr.getParent() != null) {
        expr.detach();
      }
  
      checkState(IR.mayBeExpression(expr), expr);
      return expr;
    }
docs: Returns a expression executing {@code expr} which is legal in any expression context.
  
  @param expr An attached expression
  @return A detached expression