code: public <T extends HalRepresentation> Optional<T> getResourceAs(final Class<T> type, 
                                                                     final List<EmbeddedTypeInfo> embeddedTypeInfos) throws IOException {
          checkState();
          try {
              if (startWith != null) {
                  lastResult = traverseInitialResource(type, embeddedTypeInfos, false);
              } else if (!hops.isEmpty()) {
                  lastResult = traverseHop(lastResult.get(0), type, embeddedTypeInfos, false);
              }
              if (lastResult.size() > 0) {
                  return Optional.of(type.cast(lastResult.get(0)));
              } else {
                  return Optional.empty();
              }
          } catch (final Exception e) {
              LOG.error(e.getMessage());
              throw e;
          }
      }
docs: Return the selected resource and return it in the specified type.
  <p>
  The EmbeddedTypeInfo is used to define the specific type of embedded items.
  </p>
  <p>
  If there are multiple matching representations, the first node is returned.
  </p>
  @param type the subtype of the HalRepresentation used to parse the resource.
  @param embeddedTypeInfos specification of the type of embedded items
  @param <T> the subtype of HalRepresentation of the returned resource.
  @return HalRepresentation
  @throws IOException if a low-level I/O problem (unexpected end-of-input, network error) occurs.
  @throws JsonParseException if the json document can not be parsed by Jackson's ObjectMapper
  @throws JsonMappingException if the input JSON structure can not be mapped to the specified HalRepresentation type
  @since 1.0.0