code: public static Optional<Object> firstElement(final Object obj) {
          val object = CollectionUtils.toCollection(obj);
          if (object.isEmpty()) {
              return Optional.empty();
          }
          return Optional.of(object.iterator().next());
      }
docs: Converts the provided object into a collection
  and return the first element, or empty.
  
  @param obj the obj
  @return the optional