def read_catigories():
"""Returns catigories, None if there are none."""
# LXML stuff
return page.get_catigories()
def read_products():
"""Returns products, None if there are none."""
# LXML stuff
return page.get_products()
def read_all_catigories():
cat = read_catigories()
if cat is None:
yield read_products()
else:
yield from read_all_catigories()