code: public static IReactionSet extractTopReactions(IReactionScheme reactionScheme) {
          IReactionSet reactionSet = reactionScheme.getBuilder().newInstance(IReactionSet.class);
  
          IReactionSet allSet = getAllReactions(reactionScheme);
          for (IReaction reaction : allSet.reactions()) {
              IReactionSet precuSet = extractPrecursorReaction(reaction, allSet);
              if (precuSet.getReactionCount() == 0) {
                  boolean found = false;
                  for (IReaction reactIn : reactionSet.reactions()) {
                      if (reactIn.equals(reaction)) found = true;
                  }
                  if (!found) reactionSet.addReaction(reaction);
              }
  
          }
          return reactionSet;
      }
docs: Extract a set of Reactions which are in top of a IReactionScheme. The top reactions are those
  which any of their reactants are participating in other reactions as a products.
  
  @param reactionScheme  The IReactionScheme
  @return                The set of top reactions