def filter_comments(tree):
 def traverse(tree):
  'Generator dropping comment nodes'
  for entry in tree:
   spaceless = [e for e in entry if (not nginxparser.spacey(e))]
   if spaceless:
    key = spaceless[0]
    values = (spaceless[1] if (len(spaceless) > 1) else None)
   else:
    key = values = ''
   if isinstance(key, list):
    new = copy.deepcopy(entry)
    new[1] = filter_comments(values)
    (yield new)
   elif ((key != '#') and spaceless):
    (yield spaceless)
 return list(traverse(tree))

def filter_comments ( tree ) : def traverse ( tree ) : for entry in tree : spaceless = [ e for e in entry if ( not nginxparser . spacey ( e ) ) ] if spaceless : key = spaceless [ 0 ] values = ( spaceless [ 1 ] if ( len ( spaceless ) > 1 ) else None ) else : key = values = '' if isinstance ( key , list ) : new = copy . deepcopy ( entry ) new [ 1 ] = filter_comments ( values ) ( yield new ) elif ( ( key != '#' ) and spaceless ) : ( yield spaceless ) return list ( traverse ( tree ) )
filter comment nodes from parsed configurations .