code: public static boolean matchTopics(String msgTopic, String subscriptionTopic) {
          try {
              List<Token> msgTokens = SubscriptionsStore.splitTopic(msgTopic);
              List<Token> subscriptionTokens = SubscriptionsStore.splitTopic(subscriptionTopic);
              int i = 0;
              Token subToken = null;
              for (; i< subscriptionTokens.size(); i++) {
                  subToken = subscriptionTokens.get(i);
                  if (subToken != Token.MULTI && subToken != Token.SINGLE) {
                      if (i >= msgTokens.size()) {
                          return false;
                      }
                      Token msgToken = msgTokens.get(i);
                      if (!msgToken.equals(subToken)) {
                          return false;
                      }
                  } else {
                      if (subToken == Token.MULTI) {
                          return true;
                      }
                      if (subToken == Token.SINGLE) {
                          //skip a step forward
                      }
                  }
              }
              //if last token was a SINGLE then treat it as an empty
  //            if (subToken == Token.SINGLE && (i - msgTokens.size() == 1)) {
  //               i--; 
  //            }
              return i == msgTokens.size();
          } catch (ParseException ex) {
              Log.error(null, ex);
              throw new RuntimeException(ex);
          }
      }
docs: TODO reimplement with iterators or with queues