import logging


def getLowerTabs(bookYaml):
  """Gets the lower tabs from a parsed book.yaml dictionary.

  Args:
      bookYaml: the parsed book.yaml file

  Returns:
      An array of objects with the lower tabs
  """
  result = []
  try:
    for tab in bookYaml['upper_tabs']:
      if 'lower_tabs' in tab and 'other' in tab['lower_tabs']:
        for lowerTab in tab['lower_tabs']['other']:
          lt = {}
          lt['name'] = lowerTab['name']
          if 'contents' in lowerTab and 'path' in lowerTab['contents'][0]:
            lt['path'] = lowerTab['contents'][0]['path']
            result.append(lt)
  except Exception as e:
    logging.exception('Unable to read/parse the lower tabs')
  return result