private static List<String> extractPath(UnaryRule unaryRule, Map<UnaryRule, String> intermediateStates) {
      List<String> path = new ArrayList<String>();
      path.add(unaryRule.getParent());
      String intermediateState = intermediateStates.get(unaryRule);
      if (intermediateState != null) {
        List<String> parentPath = extractPath(new UnaryRule(unaryRule.getParent(), intermediateState), intermediateStates);
        for (int i = 1; i < parentPath.size() - 1; i++) {
          String state = parentPath.get(i);
          path.add(state);
        }
        path.add(intermediateState);
        List<String> childPath = extractPath(new UnaryRule(intermediateState, unaryRule.getChild()), intermediateStates);
        for (int i = 1; i < childPath.size() - 1; i++) {
          String state = childPath.get(i);
          path.add(state);
        }
      }
      if (path.size() == 1 && unaryRule.getParent().equals(unaryRule.getChild())) return path;
      path.add(unaryRule.getChild());
      return path;
    }