/** * * Looks at the projected variables by all the child sub-trees and does the appropriate renamings. * */ private NextNodeAndQuery optimizeJoinLikeNodeChildren(IntermediateQuery query, JoinLikeNode initialJoinLikeNode) throws EmptyQueryException { // Non-final Optional<QueryNode> optionalCurrentChild = query.getFirstChild(initialJoinLikeNode); JoinLikeNode currentJoinLikeNode = initialJoinLikeNode; while (optionalCurrentChild.isPresent()) { ParentNextChild parentNextChild = optimizeFollowingChildren(query, optionalCurrentChild.get(), currentJoinLikeNode); optionalCurrentChild = parentNextChild.nextChild; currentJoinLikeNode = parentNextChild.parent; } return new NextNodeAndQuery(getDepthFirstNextNode(query, currentJoinLikeNode), query); }