/** * TODO: explain * */ private NextNodeAndQuery optimizeDataNode(IntermediateQuery currentQuery, DataNode currentNode) throws EmptyQueryException { Optional<PullVariableOutOfDataNodeProposal> optionalProposal = buildProposal(currentNode, new HashSet<>()); if (optionalProposal.isPresent()) { PullVariableOutOfDataNodeProposal proposal = optionalProposal.get(); NodeCentricOptimizationResults<DataNode> results = currentQuery.applyProposal(proposal); return getNextNodeAndQuery(currentQuery, results); } else { // NB: a DataNode is not expected to have a child return new NextNodeAndQuery(getDepthFirstNextNode(currentQuery, currentNode), currentQuery); } } }