     // MARK: Simple optional unpacking
     
     private func optionalAtPath<Value>(first: PathFragment?, _ rest: [PathFragment], ifNotFound: Swift.Bool, ifNull: Swift.Bool, @noescape getter: JSON throws -> Value) throws -> Value? {
+        var json: JSON?
         do {
-            if ifNull {
-                return try fetchNullableValueAtPath(first, rest, detectNull: true, getter: getter)
-            } else {
-                return try fetchValueAtPath(first, rest, detectNull: true, getter: getter)
-            }
+            json = try valueAtPath(first, rest, detectNull: true)
+            return try getter(unsafeUnwrap(json))
+        } catch Error.IndexOutOfBounds where ifNotFound {
+            return nil
         } catch Error.KeyNotFound where ifNotFound {
             return nil
-        } catch Error.IndexOutOfBounds where ifNotFound {
+        } catch Error.UnexpectedSubscript(let type) where ifNotFound && type == Swift.String.self {
             return nil
-        } catch SubscriptError.SubscriptIntoNull where ifNull {
+        } catch Error.ValueNotConvertible where ifNull && json == .Null {
+            return nil
+        }  catch SubscriptError.SubscriptIntoNull where ifNull {
             return nil
         } catch SubscriptError.SubscriptIntoNull(.Key) where ifNotFound {
             return nil
         } catch SubscriptError.SubscriptIntoNull(let fragment) {
             throw Error.UnexpectedSubscript(type: fragment.valueType)
-        } catch Error.UnexpectedSubscript(let type) where ifNotFound && type == Swift.String {
-            return nil
         }
     }
     

    /// - throws: One of the `JSON.Error` cases thrown by `decode(_:or:)`.
    /// - seealso: `JSON.decode(_:or:)`
    public func array(first: PathFragment? = nil, _ rest: PathFragment..., @autoclosure or fallback: () -> [JSON]) throws -> [JSON] {
        //
        let array = try optionalAtPath(first, rest, ifNotFound: true, ifNull: false) { try $0.array() }
        return array ?? fallback()
    }

//

// MARK: - Subscripting


extension JSON {
    
