public default <A> A get(final String label) throws IllegalArgumentException {
        final List<Object> objects = this.objects();
        final List<Set<String>> labels = this.labels();
        Optional<Object> object = null;
        for (int i = 0; i < labels.size(); i++) {
            if (labels.get(i).contains(label)) {
                if (null == object) {
                    object = Optional.ofNullable(objects.get(i));
                } else if (object.get() instanceof List) {
                    ((List) object.get()).add(objects.get(i));
                } else {
                    final List<Object> list = new ArrayList<>(2);
                    list.add(object.get());
                    list.add(objects.get(i));
                    object = Optional.of(list);
                }
            }
        }

        if (null == object) throw Path.Exceptions.stepWithProvidedLabelDoesNotExist(label);

        return (A) object.orElse(null);
    }
Get the object associated with the particular label of the path.
If the path as multiple labels of the type, then return a {@link List} of those objects.

@param label the label of the path
@param <A>   the type of the object associated with the label
@return the object associated with the label of the path
@throws IllegalArgumentException if the path does not contain the label
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Path.java