def get_units_with_due_date(course):
 units = []
 def visit(node):
  '\n        Visit a node.  Checks to see if node has a due date and appends to\n        `units` if it does.  Otherwise recurses into children to search for\n        nodes with due dates.\n        '
  if getattr(node, 'due', None):
   units.append(node)
  else:
   for child in node.get_children():
    visit(child)
 visit(course)
 return units

def get_units_with_due_date ( course ) : units = [ ] def visit ( node ) : if getattr ( node , 'due' , None ) : units . append ( node ) else : for child in node . get_children ( ) : visit ( child ) visit ( course ) return units
returns all top level units which have due dates .