code: function getReferenceExpression ( expression ) {
    	var members = [], refinement;
  
    	while ( expression.t === MEMBER && expression.r.t === REFINEMENT ) {
    		refinement = expression.r;
  
    		if ( refinement.x ) {
    			if ( refinement.x.t === REFERENCE ) {
    				members.unshift( refinement.x );
    			} else {
    				members.unshift( flattenExpression( refinement.x ) );
    			}
    		} else {
    			members.unshift( refinement.n );
    		}
  
    		expression = expression.x;
    	}
  
    	if ( expression.t !== REFERENCE ) {
    		return null;
    	}
  
    	return {
    		r: expression.n,
    		m: members
    	};
    }
docs: TODO refactor this! it's bewildering