@Override
    public boolean popEquals(final Pop pop, final Object other) {
        if (!(other instanceof Path))
            return false;
        final Path otherPath = (Path) other;
        ImmutablePath currentPath = this;
        while (true) {
            if (currentPath.isTail())
                break;
            for (final String label : currentPath.currentLabels) {
                if (!otherPath.hasLabel(label)) return false;

                final Object o1 = this.get(pop, label);
                final Object o2 = otherPath.get(pop, label);
                if (o1 != null && !o1.equals(o2)) return false;
            }
            currentPath = currentPath.previousPath;
        }
        return true;
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/ImmutablePath.java