/* eslint-env amd */
(function (name, definition) {
  if (typeof define === 'function') {
    // AMD
    define(definition)
  } else if (typeof module !== 'undefined' && module.exports) {
    // Node.js
    module.exports = definition()
  } else {
    // Browser
    window[name] = definition()
  }
})('nullPrune', function () {
  function hasOwnProperty (obj, property) {
    return Object.prototype.hasOwnProperty.call(obj, property)
  }

  function isObject (input) {
    return input && (typeof input === 'object')
  }

  function keys (obj) {
    var key
    var ownKeys = []

    for (key in obj) {
      if (hasOwnProperty(obj, key)) {
        ownKeys.push(key)
      }
    }

    return ownKeys
  }

  function nullPrune (inputObject, context) {
    var objectKey = context.objectKey
    var parentObject = context.parentObject

    keys(inputObject).forEach(function (key) {
      var node = inputObject[key]

      if (isObject(node)) {
        nullPrune(node, {
          objectKey: key,
          parentObject: inputObject
        })
      } else if (node == null) {
        delete inputObject[key]
      }
    })

    if (parentObject && keys(inputObject).length === 0) {
      delete parentObject[objectKey]
    }
  }

  return function (inputObject) {
    if (!isObject(inputObject)) {
      return inputObject
    }

    nullPrune(inputObject, {})
    return inputObject
  }
})

@@ -326,120 +326,8 @@
 ) %7B%0A
-  function hasOwnProperty (obj, property) %7B%0A    return Object.prototype.hasOwnProperty.call(obj, property)%0A  %7D%0A%0A
   fu
@@ -416,17 +416,20 @@
 unction 
-k
+ownK
 eys (obj
@@ -464,16 +464,73 @@
 eys = %5B%5D
+%0A    var hasOwnProperty = Object.prototype.hasOwnProperty
 %0A%0A    fo
@@ -570,16 +570,21 @@
 Property
+.call
 (obj, ke
@@ -786,52 +786,98 @@
 ect%0A
-%0A
     
-keys(inputObject).forEach(functio
+var keys = ownKeys(inputObject)%0A    var k%0A    var key%0A    var node%0A%0A    for (k i
 n 
-(
 key
+s
 ) %7B%0A
@@ -878,27 +878,43 @@
 ys) %7B%0A      
-var
+key = keys%5Bk%5D%0A     
  node = inpu
@@ -1132,17 +1132,16 @@
  %7D%0A    %7D
-)
 %0A%0A    if
@@ -1158,17 +1158,20 @@
 ject && 
-k
+ownK
 eys(inpu

Make it compatible with old browsers