public static boolean inherits(RObject obj, String attr) {
    if (obj == null) {
      return false;
    }

    RList att = obj.getAttributes();
    if (att == null) {
      return false;
    }

    String[] names = att.getNames();
    for (int i = 0; i < names.length; i++) {
      if ("class".equals(names[i])) {
        RObject cl = att.getValue()[i];
        if (cl != null && cl instanceof RChar) {
          RChar clCh = (RChar) cl;
          for (String s : clCh.getValue()) {
            if (attr.equals(s)) {
              return true;
            }
          }
        }
      }
    }

    return false;
  }