The method <code>traverseQPath</code> implemented thanks to simple queries. It allows
to use Simple Queries instead of Complex Queries when complex queries are much slower such
as with HSQLDB for example.
358948
protected QPath traverseQPathSQ(String cpid) throws SQLException, InvalidItemStateException, IllegalNameException
   {
      // get item by Identifier usecase 
      List<QPathEntry> qrpath = new ArrayList<QPathEntry>(); // reverted path
      String caid = cpid; // container ancestor id
      do
      {
         ResultSet parent = findItemByIdentifier(caid);
         try
         {
            if (!parent.next())
            {
               throw new InvalidItemStateException("Parent not found, uuid: " + getIdentifier(caid));
            }

            QPathEntry qpe =
               new QPathEntry(InternalQName.parse(parent.getString(COLUMN_NAME)), parent.getInt(COLUMN_INDEX), getIdentifier(caid));
            qrpath.add(qpe);
            caid = parent.getString(COLUMN_PARENTID);

            if (caid.equals(parent.getString(COLUMN_ID)))
            {
               throw new InvalidItemStateException("An item with id='" + getIdentifier(caid) + "' is its own parent");
            }
         }
         finally
         {
            try
            {
               parent.close();
            }
            catch (SQLException e)
            {
               LOG.error("Can't close the ResultSet: " + e.getMessage());
            }
         }
      }
      while (!caid.equals(Constants.ROOT_PARENT_UUID));

      QPathEntry[] qentries = new QPathEntry[qrpath.size()];
      int qi = 0;
      for (int i = qrpath.size() - 1; i >= 0; i--)
      {
         qentries[qi++] = qrpath.get(i);
      }
      return new QPath(qentries);
   }
1370596
@WithBridgeMethods(value = PostgreSQLQuery.class, castRequired = true)
    public C of(RelationalPath<?>... paths) {
        StringBuilder builder = new StringBuilder(" of ");
        for (RelationalPath<?> path : paths) {
            if (builder.length() > 4) {
                builder.append(", ");
            }
            builder.append(getConfiguration().getTemplates().quoteIdentifier(path.getTableName()));
        }
        return addFlag(Position.END, builder.toString());
    }
964396
function withQuery(path, query) {
    var existingQuery = PathUtils.extractQuery(path);

    if (existingQuery) query = query ? assign(existingQuery, query) : existingQuery;

    var queryString = qs.stringify(query, { arrayFormat: 'brackets' });

    if (queryString) {
      return PathUtils.withoutQuery(path) + '?' + queryString;
    }return PathUtils.withoutQuery(path);
  }
409335
private void treeWalker(Node node, int level, List<PathQueryMatcher> queryMatchers, List<Node> collector) {
        MatchType matchType = queryMatchers.get(level).match(level, node);
        if(matchType == MatchType.NOT_A_MATCH) {
            // no reason to scan deeper
            //noinspection UnnecessaryReturnStatement
            return;
        } else if(matchType == MatchType.NODE_MATCH) {
            // we have a match
            if(level == queryMatchers.size()-1) {
                // full path match
                collector.add(node);
            } else if(node instanceof Element) {
                // scan deeper
                Element element = (Element) node;
                List<Node> childElements = element.getChildElements();
                for (Node childElement : childElements) {
                    treeWalker(childElement, level+1, queryMatchers, collector);
                }
            }
        } else {
            throw new PathQueryException("Unknown MatchType: " + matchType);
        }
    }
27121
private <T> QueryRequest<T> query(String fql, JavaType type) {
		this.checkForBatchExecution();
		
		if (this.multiqueryRequest == null) {
			this.multiqueryRequest = new MultiqueryRequest(mapper, this.createUnmappedChain());
			this.graphRequests.add(this.multiqueryRequest);
		}
		
		// There is a circular reference between the extractor and request, so construction of the chain
		// is a little complicated
		QueryNodeExtractor extractor = new QueryNodeExtractor(this.multiqueryRequest);
		
		String name = "__q" + this.generatedQueryNameIndex++;
		QueryRequest<T> q =
			new QueryRequest<T>(fql, name,
				new MapperWrapper<T>(type, this.mapper,
						extractor));
		
		extractor.setRequest(q);
		
		this.multiqueryRequest.addQuery(q);
		return q;
	}
574795
def path_upper(
        cls, object_id, limit_depth=1000000, db_session=None, *args, **kwargs
    ):
        
        tablename = cls.model.__table__.name
        raw_q = """
            WITH RECURSIVE subtree AS (
                    SELECT res.*, 1 as depth FROM {tablename} res
                    WHERE res.resource_id = :resource_id
                  UNION ALL
                    SELECT res_u.*, depth+1 as depth
                    FROM {tablename} res_u, subtree st
                    WHERE res_u.resource_id = st.parent_id
            )
            SELECT * FROM subtree WHERE depth<=:depth;
        """.format(
            tablename=tablename
        )
        db_session = get_db_session(db_session)
        q = (
            db_session.query(cls.model)
            .from_statement(sa.text(raw_q))
            .params(resource_id=object_id, depth=limit_depth)
        )
        return q
790120
public Optional<DataType> get( Object tree, List<String> keys ) {

        if ( keys.size() != traversalLength ) {
            throw new TraversrException( "Traversal Path and number of keys mismatch, traversalLength:" + traversalLength + " numKeys:" + keys.size() );
        }

        return root.traverse( tree, TraversalStep.Operation.GET, keys.iterator(), null );
    }
550022
private void applyRelativePath(RelationQueryNode node) {
       if (tmpRelPath != null)
       {
          // try {
          QPath relPath = tmpRelPath;
          for (int i = 0; i < relPath.getEntries().length; i++)
          {
             node.addPathElement(relPath.getEntries()[i]);
          }
          tmpRelPath = null;
       }
    }
138638
public static <T> Promise traverse(List<Supplier<Promise<T>>> queue) {

        if (queue.size() == 0) {
            return Promise.success(null);
        }

        return queue.remove(0).get()
                .flatMap(v -> traverse(queue));
    }
1309420
def select(*queries, **kwargs):
    
    def make_query(*args):
        def simple_query(nodes):
            if len(args) == 0:
                return nodes
            pred = args[0]
            results = []
            if isinstance(pred, list):
                funcs = [make_query(q) for q in pred]
                return __or(funcs, nodes)
            elif isinstance(pred, tuple):
                name, attrs = pred[0], pred[1:]
                name_pred = __make_name_pred(name)
                attrs_pred = __make_attrs_pred(attrs)
                for n in nodes:
                    if name_pred(n.name) and attrs_pred(n.attrs):
                        results.append(n)
            else:
                name_pred = __make_name_pred(pred)
                for n in nodes:
                    if name_pred(n.name):
                        results.append(n)
            return results
        if len(args) > 1:
            return __compose(make_query(*args[1:]), simple_query)
        return simple_query

    def deep_query(query, nodes):
        """ Slide the query down the branches. """
        def inner(children):
            results = []
            for c in children:
                if query([c]):
                    results.append(c)
                results.extend(inner(c.children))
            return results
        return inner(nodes)

    def unique(roots):
        seen = set()
        results = []
        for r in roots:
            if r not in seen:
                seen.add(r)
                results.append(r)
        return results

    def compiled_query(nodes):
        """
        This is the compiled query that can be run against a configuration.
        """
        query = make_query(*queries)

        roots = kwargs.get("roots", True)
        if kwargs.get("deep", False):
            results = deep_query(query, nodes)
            if roots:
                results = unique([r.root for r in results])
        elif roots:
            results = unique([n.root for n in query(nodes)])
        else:
            results = query(nodes)

        one = kwargs.get("one")
        if one is None:
            return SearchResult(children=results)
        return results[one] if results else None
    return compiled_query
941515
private void traverse(final Path path, final boolean watch, final boolean remove) {
		log.debug("traverse start. path : {}, watch : {}, remove : {}", path, watch, remove);
		if (Files.notExists(path)) {
			return;
		}
		if (Files.isDirectory(path)) {
			if (validPath(path)) {
				try (DirectoryStream<Path> ds = Files.newDirectoryStream(path)) {
					if (watch) {
						WatchKey key = path.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
						watchDirs.put(key, path);
					}
					for (Path child : ds) {
						traverse(child, watch, remove);
					}
				} catch (IOException ex) {
					throw new UroborosqlRuntimeException("I/O error occured.", ex);
				}
			}
		} else if (path.toString().endsWith(fileExtension)) {
			String sqlName = getSqlName(path);
			this.sqlInfos.compute(sqlName,
					(k, v) -> v == null ? new SqlInfo(sqlName, path, dialect, charset) : v.computePath(path, remove));
		}
	}
661377
private String constructDuplicatePathSql(SqlgGraph sqlgGraph, List<LinkedList<SchemaTableTree>> subQueryLinkedLists, Set<SchemaTableTree> leftJoinOn) {
        StringBuilder singlePathSql = new StringBuilder("\nFROM (");
        int count = 1;
        SchemaTableTree lastOfPrevious = null;
        for (LinkedList<SchemaTableTree> subQueryLinkedList : subQueryLinkedLists) {
            SchemaTableTree firstOfNext = null;
            boolean last = count == subQueryLinkedLists.size();
            if (!last) {
                //this is to get the next SchemaTable to join to
                LinkedList<SchemaTableTree> nextList = subQueryLinkedLists.get(count);
                firstOfNext = nextList.getFirst();
            }
            SchemaTableTree firstSchemaTableTree = subQueryLinkedList.getFirst();

            String sql;
            if (last) {
                //only the last step must have dropStep as true. As only the outer select needs only an ID in the select
                sql = constructSinglePathSql(sqlgGraph, true, subQueryLinkedList, lastOfPrevious, null, leftJoinOn, false);
            } else {
                sql = constructSinglePathSql(sqlgGraph, true, subQueryLinkedList, lastOfPrevious, firstOfNext);
            }
            singlePathSql.append(sql);
            if (count == 1) {
                singlePathSql.append("\n) a").append(count++).append(" INNER JOIN (");
            } else {
                //join the last with the first
                singlePathSql.append("\n) a").append(count).append(" ON ");
                singlePathSql.append(constructSectionedJoin(sqlgGraph, lastOfPrevious, firstSchemaTableTree, count));
                if (count++ < subQueryLinkedLists.size()) {
                    singlePathSql.append(" INNER JOIN (");
                }
            }
            lastOfPrevious = subQueryLinkedList.getLast();
        }
        singlePathSql.append(constructOuterOrderByClause(sqlgGraph, subQueryLinkedLists));
        String result = "SELECT\n\t" + constructOuterFromClause(subQueryLinkedLists);
        return result + singlePathSql;
    }
348107
function traverseObject(toSearchObj, searchForObj) {
    const allKeys = Object.keys(toSearchObj);
    const len = allKeys.length;

    for (let i = 0; i < len; i++) {
      const key = allKeys[i];
      const val = toSearchObj[key];

      if (searchForObj[key] && !results[key]) {
        results[key] = val;
      } else if (isObject(val)) {
        traverseObject(val, searchForObj);
      } else if (isArray(val)) {
        traverseArray(val, searchForObj);
      }
    }
  }
361931
private static ArrayList<SimpleEntry<String, String>> traverseNode(Node n, String p) {
        ArrayList<SimpleEntry<String, String>> output = new ArrayList<>();
        String nName;
        if (n.getNodeType() != Node.TEXT_NODE) {
            nName = n.getNodeName();
            if (nName.startsWith("m:")) {
                nName = nName.substring(2);
            }
            if (nName.equals("mws:qvar")) {
                return new ArrayList<>();
            }
            p += "/" + nName;
        }
        String nValue = n.getNodeValue();
        if (nValue != null) {
            nValue = nValue.trim();
            if (nValue.length() == 0) {
                return new ArrayList<>();
            }
        } else {
            nValue = "";
        }

        if (!n.hasChildNodes()) {
            output.add(new SimpleEntry<>(p, nValue));
        } else {
            for (int i = 0; i < n.getChildNodes().getLength(); i++) {
                output.addAll(traverseNode(n.getChildNodes().item(i), p));
            }
        }
        return output;
    }
1285970
function traverseBroad(object, visitor) {
        var key, child;

        if (!object) {
            return;
        }

        if (visitor.call(null, object) === false) {
            return false;
        }
        for (key in object) {
            if (object.hasOwnProperty(key)) {
                child = object[key];
                if (typeof child === 'object' && child !== null) {
                    traverseBroad(child, visitor);
                }
            }
        }
    }
948167
function(obj, visitor, context, traversalStrategy) {
      traversalStrategy = traversalStrategy || this._traversalStrategy;
      walkImpl(obj, traversalStrategy, null, visitor, context);
    }
1016367
private void traverseNode(String path) {
        DataNode node = getNode(path);
        String children[] = null;
        synchronized (node) {
            Set<String> childs = node.getChildren();
            if (childs != null) {
                children = childs.toArray(new String[childs.size()]);
            }
        }
        if (children != null) {
            if (children.length == 0) {
                // this node does not have a child
                // is the leaf node
                // check if its the leaf node
                String endString = "/" + Quotas.limitNode;
                if (path.endsWith(endString)) {
                    // ok this is the limit node
                    // get the real node and update
                    // the count and the bytes
                    String realPath = path.substring(Quotas.quotaZookeeper
                            .length(), path.indexOf(endString));
                    updateQuotaForPath(realPath);
                    this.pTrie.addPath(realPath);
                }
                return;
            }
            for (String child : children) {
                traverseNode(path + "/" + child);
            }
        }
    }