flatToBullets' num xs@(b : elems)
  | getLevelN b == num = b : (flatToBullets' num elems)
  | otherwise =
    let bNumId = getNumIdN b
        bLevel = getLevelN b
        (children, remaining) =
          span
          (\b' ->
            ((getLevelN b') > bLevel ||
             ((getLevelN b') == bLevel && (getNumIdN b') == bNumId)))
          xs
    in
     case getListType b of
       Just (Enumerated attr) ->
         (OrderedList attr (separateBlocks $ flatToBullets' bLevel children)) :
         (flatToBullets' num remaining)
       _ ->
         (BulletList (separateBlocks $ flatToBullets' bLevel children)) :
         (flatToBullets' num remaining)
flatToBullets' num xs@(b : elems)
  | getLevelN b == num = b : (flatToBullets' num elems)
  | otherwise =
    let bNumId = getNumIdN b
        bLevel = getLevelN b
        (children, remaining) =
          span
          (\b' ->
            ((getLevelN b') > bLevel ||
             ((getLevelN b') == bLevel && (getNumIdN b') == bNumId)))
          xs
    in
     case getListType b of
       Just (Enumerated attr) ->
         (OrderedList attr (separateBlocks $ flatToBullets' bLevel children)) :
         (flatToBullets' num remaining)
       _ ->
         (BulletList (separateBlocks $ flatToBullets' bLevel children)) :
         (flatToBullets' num remaining)
flatToBullets' num xs@(b : elems)
  | getLevelN b == num = b : (flatToBullets' num elems)
  | otherwise =
    let bNumId = getNumIdN b
        bLevel = getLevelN b
        (children, remaining) =
          span
          (\b' ->
            ((getLevelN b') > bLevel ||
             ((getLevelN b') == bLevel && (getNumIdN b') == bNumId)))
          xs
    in
     case getListType b of
       Just (Enumerated attr) ->
         (OrderedList attr (separateBlocks $ flatToBullets' bLevel children)) :
         (flatToBullets' num remaining)
       _ ->
         (BulletList (separateBlocks $ flatToBullets' bLevel children)) :
         (flatToBullets' num remaining)