function walk(node, root_node, prev) {
		var sibling, parent, startName = prev ? 'lastChild' : 'firstChild', siblingName = prev ? 'prev' : 'next';

		// Walk into nodes if it has a start
		if (node[startName])
			return node[startName];

		// Return the sibling if it has one
		if (node !== root_node) {
			sibling = node[siblingName];

			if (sibling)
				return sibling;

			// Walk up the parents to look for siblings
			for (parent = node.parent; parent && parent !== root_node; parent = parent.parent) {
				sibling = parent[siblingName];

				if (sibling)
					return sibling;
			}
		}
	}
function walk(node, root_node, prev) {
		var sibling, parent, startName = prev ? 'lastChild' : 'firstChild', siblingName = prev ? 'prev' : 'next';

		
		if (node[startName])
			return node[startName];

		
		if (node !== root_node) {
			sibling = node[siblingName];

			if (sibling)
				return sibling;

			
			for (parent = node.parent; parent && parent !== root_node; parent = parent.parent) {
				sibling = parent[siblingName];

				if (sibling)
					return sibling;
			}
		}
	}
function walk ( node , root_node , prev ) { var sibling , parent , startName = prev ? 'lastChild' : 'firstChild' , siblingName = prev ? 'prev' : 'next' ; // Walk into nodes if it has a start
 if ( node [ startName ] ) return node [ startName ] ; // Return the sibling if it has one
 if ( node !== root_node ) { sibling = node [ siblingName ] ; if ( sibling ) return sibling ; // Walk up the parents to look for siblings
 for ( parent = node . parent ; parent && parent !== root_node ; parent = parent . parent ) { sibling = parent [ siblingName ] ; if ( sibling ) return sibling ; } } }
Walks the tree left/right
Walks the tree left / right