code: private NodeCentricOptimizationResults<InnerJoinNode> applyOptimization(IntermediateQuery query,
                                                                                       QueryTreeComponent treeComponent,
                                                                                       InnerJoinNode topJoinNode,
                                                                                       ConcreteProposal proposal)
              throws EmptyQueryException {
          /*
           * First, add and remove non-top nodes
           */
          proposal.getDataNodesToRemove()
                  .forEach(treeComponent::removeSubTree);
  
          return updateJoinNodeAndPropagateSubstitution(query, treeComponent, topJoinNode, proposal);
      }
docs: Assumes that the data atoms are leafs.