def _normal_ordered_form_terms(expr, independent=False, recursive_limit=10, _recursive_depth=0):
 new_terms = []
 for term in expr.args:
  if isinstance(term, Mul):
   new_term = _normal_ordered_form_factor(term, recursive_limit=recursive_limit, _recursive_depth=_recursive_depth, independent=independent)
   new_terms.append(new_term)
  else:
   new_terms.append(term)
 return Add(*new_terms)

def _normal_ordered_form_terms ( expr , independent = False , recursive_limit = 10 , _recursive_depth = 0 ) : new_terms = [ ] for term in expr . args : if isinstance ( term , Mul ) : new_term = _normal_ordered_form_factor ( term , recursive_limit = recursive_limit , _recursive_depth = _recursive_depth , independent = independent ) new_terms . append ( new_term ) else : new_terms . append ( term ) return Add ( * new_terms )
helper function for normal_ordered_form: loop through each term in an addition expression and call _normal_ordered_form_factor to perform the factor to an normally ordered expression .