src/node/js/node.js
function(method, criteria) {
	// Iterate on the raw node
	var node = this._node,

		// Method to iterate on
		siblingType = method + 'Sibling',

		// Filter to test the node
		filter,

		validItems;

	// CSS Selector case
	if (typeof criteria == "string") {
		validItems = n.all(criteria);
		filter = function(rawNode) {
			var found = false;
			
			validItems.each(function(el){
				if (rawNode == el._node) {
					found = true;
				}
			});
			return found;
		}; 

	// Default the filter to return true
	} else if (!criteria) {
		filter = function(){ return true }
	} else {
		filter = function(rawEl) {
			return criteria(new NWTNodeInstance(rawEl));
		}
	}

	while(node) {
		node = node[siblingType];

		if (node && node.nodeType == 1 && filter(node)) {
			break;
		}	
	}

	return node ? new NWTNodeInstance(node) : null;
}
function(method, criteria) {
	// Iterate on the raw node
	var node = this._node,

		// Method to iterate on
		siblingType = method + 'Sibling',

		// Filter to test the node
		filter,

		validItems;

	// CSS Selector case
	if (typeof criteria == "string") {
		validItems = n.all(criteria);
		filter = function(rawNode) {
			var found = false;
			
			validItems.each(function(el){
				if (rawNode == el._node) {
					found = true;
				}
			});
			return found;
		}; 

	// Default the filter to return true
	} else if (!criteria) {
		filter = function(){ return true }
	} else {
		filter = function(rawEl) {
			return criteria(new NWTNodeInstance(rawEl));
		}
	}

	while(node) {
		node = node[siblingType];

		if (node && node.nodeType == 1 && filter(node)) {
			break;
		}	
	}

	return node ? new NWTNodeInstance(node) : null;
}
function ( method , criteria ) { // Iterate on the raw node var node = this . _node , // Method to iterate on siblingType = method + 'Sibling' , // Filter to test the node filter , validItems ; // CSS Selector case if ( typeof criteria == "string" ) { validItems = n . all ( criteria ) ; filter = function ( rawNode ) { var found = false ; validItems . each ( function ( el ) { if ( rawNode == el . _node ) { found = true ; } } ) ; return found ; } ; // Default the filter to return true } else if ( ! criteria ) { filter = function ( ) { return true } } else { filter = function ( rawEl ) { return criteria ( new NWTNodeInstance ( rawEl ) ) ; } } while ( node ) { node = node [ siblingType ] ; if ( node && node . nodeType == 1 && filter ( node ) ) { break ; } } return node ? new NWTNodeInstance ( node ) : null ; }
Finds a node based on direction
@param string Native method to iterate nodes {previous | next}
@param string criteria CSS selector or Filtering function
Finds a node based on direction