def unwrap_order_by(clause):
 cols = util.column_set()
 result = []
 stack = deque([clause])
 while stack:
  t = stack.popleft()
  if (isinstance(t, ColumnElement) and ((not isinstance(t, UnaryExpression)) or (not operators.is_ordering_modifier(t.modifier)))):
   if isinstance(t, _label_reference):
    t = t.element
   if isinstance(t, _textual_label_reference):
    continue
   if (t not in cols):
    cols.add(t)
    result.append(t)
  else:
   for c in t.get_children():
    stack.append(c)
 return result

def unwrap_order_by ( clause ) : cols = util . column_set ( ) result = [ ] stack = deque ( [ clause ] ) while stack : t = stack . popleft ( ) if ( isinstance ( t , ColumnElement ) and ( ( not isinstance ( t , UnaryExpression ) ) or ( not operators . is_ordering_modifier ( t . modifier ) ) ) ) : if isinstance ( t , _label_reference ) : t = t . element if isinstance ( t , _textual_label_reference ) : continue if ( t not in cols ) : cols . add ( t ) result . append ( t ) else : for c in t . get_children ( ) : stack . append ( c ) return result
break up an order by expression into individual column-expressions .