function index(element) {
  var i = 0;
  var elementToCheck = element;

  if (elementToCheck.previousSibling) {
    /* eslint-disable no-cond-assign */
    while (elementToCheck = elementToCheck.previousSibling) {
      i += 1;
    }
  }

  return i;
}
Counts index of element within its parent
WARNING: for performance reasons, assumes there are only element nodes (no text nodes). This is true for Walkotnable
Otherwise would need to check for nodeType or use previousElementSibling

@see http://jsperf.com/sibling-index/10
@param {Element} element
@return {Number}