code: public static ImmutableList<JoinOrFilterNode> extractFilterAndInnerJoinNodes(InnerJoinNode topJoinNode,
                                                                                   IntermediateQuery query) {
  
          ImmutableList.Builder<JoinOrFilterNode> joinAndFilterNodeBuilder = ImmutableList.builder();
          Queue<JoinOrFilterNode> nodesToExplore = new LinkedList<>();
  
          nodesToExplore.add(topJoinNode);
          joinAndFilterNodeBuilder.add(topJoinNode);
  
          while (!nodesToExplore.isEmpty()) {
              JoinOrFilterNode joinNode = nodesToExplore.poll();
  
              /**
               * Children: only considers the inner joins and the filter nodes.
               */
              for (QueryNode child : query.getChildren(joinNode)) {
                  if ((child instanceof InnerJoinNode)
                          || (child instanceof FilterNode)) {
  
                      JoinOrFilterNode joinOrFilterChild = (JoinOrFilterNode) child;
  
                      // Continues exploring
                      nodesToExplore.add(joinOrFilterChild);
                      joinAndFilterNodeBuilder.add(joinOrFilterChild);
                  }
              }
          }
          return joinAndFilterNodeBuilder.build();
      }
docs: TODO: find a better name
  TODO: explain