@Override
    public void keepLabels(final Set<String> labels) {
        final Set<String> retractLabels = new HashSet<>();
        for (final Set<String> stepLabels : this.path.labels()) {
            for (final String l : stepLabels) {
                if (!labels.contains(l))
                    retractLabels.add(l);
            }
        }
        this.path = this.path.retract(retractLabels);
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/LP_O_OB_P_S_SE_SL_Traverser.java