versions/0.2.2/oj.js
function _flattenCSSMap_(cssMap, flatMapAcc, selectorsAcc, mediasAcc, plugin){

    // Built in media helpers
    var acc, cur, inner, isMedia, mediaJoined, mediasNext, next, outer, parts, rules, selector, selectorJoined, selectorsNext, o, i,

    medias = {
      'widescreen': 'only screen and (min-width: 1200px)',
      'monitor': '',
      'tablet': 'only screen and (min-width: 768px) and (max-width: 959px)',
      'phone': 'only screen and (max-width: 767px)'
    }

    for (selector in cssMap){
      rules = cssMap[selector]

      // Base Case: Record our selector when `rules` is a value
      if (typeof rules !== 'object'){

        // Join selectors and media accumulators with commas
        selectorJoined = selectorsAcc.sort().join(',')
        mediaJoined = mediasAcc.sort().join(',')

        // Prepend @media as that was removed previously when spliting into parts
        if (mediaJoined !== '')
          mediaJoined = "@media " + mediaJoined

        // Record the rule deeply in `flatMapAcc`
        _setObject(flatMapAcc, plugin, mediaJoined, selectorJoined, selector, rules)
      // Recursive Case: Recurse on `rules` when it is an object
      } else {

        // (r1) Media Query found: Generate the next media queries
        if (selector.indexOf('@media') === 0){
          isMedia = true
          mediasNext = next = []
          selectorsNext = selectorsAcc
          selector = (selector.slice('@media'.length)).trim()
          acc = mediasAcc

        // (r2) Selector found: Generate the next selectors
        } else {
          isMedia = false
          selectorsNext = next = []
          mediasNext = mediasAcc
          acc = selectorsAcc
        }

        // Media queries and Selectors can be comma seperated
        parts = _splitAndTrim(selector, ',')

        // Media queries have convience substitutions like 'phone', 'tablet'
        if (isMedia){
          parts = parts.map(function(v){
            return _d(medias[v], v)
          })
        }

        // Determine the next selectors or media queries
        for (o = 0; o < acc.length; o++){
          outer = acc[o]

          for (i = 0; i < parts.length; i++){
            inner = parts[i]

            // When `&` is not present just insert in front with the correct join operator
            cur = inner
            if ((inner.indexOf('&')) === -1 && outer !== '')
              cur = (isMedia ? '& and ' : '& ') + cur

            next.push(cur.replace(/&/g, outer))
          }
        }

        // Recurse through objects after calculating the next selectors
        _flattenCSSMap_(
          rules, flatMapAcc, selectorsNext, mediasNext, plugin
        )
      }
    }
  }
function _flattenCSSMap_(cssMap, flatMapAcc, selectorsAcc, mediasAcc, plugin){

    // Built in media helpers
    var acc, cur, inner, isMedia, mediaJoined, mediasNext, next, outer, parts, rules, selector, selectorJoined, selectorsNext, o, i,

    medias = {
      'widescreen': 'only screen and (min-width: 1200px)',
      'monitor': '',
      'tablet': 'only screen and (min-width: 768px) and (max-width: 959px)',
      'phone': 'only screen and (max-width: 767px)'
    }

    for (selector in cssMap){
      rules = cssMap[selector]

      // Base Case: Record our selector when `rules` is a value
      if (typeof rules !== 'object'){

        // Join selectors and media accumulators with commas
        selectorJoined = selectorsAcc.sort().join(',')
        mediaJoined = mediasAcc.sort().join(',')

        // Prepend @media as that was removed previously when spliting into parts
        if (mediaJoined !== '')
          mediaJoined = "@media " + mediaJoined

        // Record the rule deeply in `flatMapAcc`
        _setObject(flatMapAcc, plugin, mediaJoined, selectorJoined, selector, rules)
      // Recursive Case: Recurse on `rules` when it is an object
      } else {

        // (r1) Media Query found: Generate the next media queries
        if (selector.indexOf('@media') === 0){
          isMedia = true
          mediasNext = next = []
          selectorsNext = selectorsAcc
          selector = (selector.slice('@media'.length)).trim()
          acc = mediasAcc

        // (r2) Selector found: Generate the next selectors
        } else {
          isMedia = false
          selectorsNext = next = []
          mediasNext = mediasAcc
          acc = selectorsAcc
        }

        // Media queries and Selectors can be comma seperated
        parts = _splitAndTrim(selector, ',')

        // Media queries have convience substitutions like 'phone', 'tablet'
        if (isMedia){
          parts = parts.map(function(v){
            return _d(medias[v], v)
          })
        }

        // Determine the next selectors or media queries
        for (o = 0; o < acc.length; o++){
          outer = acc[o]

          for (i = 0; i < parts.length; i++){
            inner = parts[i]

            // When `&` is not present just insert in front with the correct join operator
            cur = inner
            if ((inner.indexOf('&')) === -1 && outer !== '')
              cur = (isMedia ? '& and ' : '& ') + cur

            next.push(cur.replace(/&/g, outer))
          }
        }

        // Recurse through objects after calculating the next selectors
        _flattenCSSMap_(
          rules, flatMapAcc, selectorsNext, mediasNext, plugin
        )
      }
    }
  }
Recursive helper with accumulators (it outputs flatMapAcc)