public static Optional<Property> getProperty(final Attachable<Property> attachableProperty, final Graph hostGraph) {
            final Property baseProperty = attachableProperty.get();
            final Element propertyElement = attachableProperty.get().element();
            if (propertyElement instanceof Vertex) {
                return (Optional) Method.getVertexProperty((Attachable) attachableProperty, hostGraph);
            } else if (propertyElement instanceof Edge) {
                final Iterator<Edge> edgeIterator = hostGraph.edges(propertyElement.id());
                while (edgeIterator.hasNext()) {
                    final Property property = edgeIterator.next().property(baseProperty.key());
                    if (property.isPresent() && property.value().equals(baseProperty.value()))
                        return Optional.of(property);
                }
                return Optional.empty();
            } else { // vertex property
                final Iterator<Vertex> vertexIterator = hostGraph.vertices(((VertexProperty) propertyElement).element().id());
                if (vertexIterator.hasNext()) {
                    final Iterator<VertexProperty<Object>> vertexPropertyIterator = vertexIterator.next().properties();
                    while (vertexPropertyIterator.hasNext()) {
                        final VertexProperty vertexProperty = vertexPropertyIterator.next();
                        if (ElementHelper.areEqual(vertexProperty, baseProperty.element())) {
                            final Property property = vertexProperty.property(baseProperty.key());
                            if (property.isPresent() && property.value().equals(baseProperty.value()))
                                return Optional.of(property);
                            else
                                return Optional.empty();
                        }
                    }
                }
                return Optional.empty();
            }
        }
A collection of general methods of attachment. Note that more efficient methods of attachment might exist
if the user knows the source data being attached and the features of the graph that the data is being
attached to.
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java