docs: def get_children(engine, parent_ids, rank='species', schema=None):
      """
      Recursively fetch children of tax_ids in `parent_ids` until the
      rank of `rank`
      """
  
      if not parent_ids:
          return []
  
      nodes = schema + '.nodes' if schema else 'nodes'
      names = schema + '.names' if schema else 'names'
  
      cmd = ('select tax_id, tax_name, rank '
             'from {} join {} using (tax_id) '
             'where parent_id = :tax_id and is_primary').format(nodes, names)
  
      species = []
      for parent_id in parent_ids:
          result = engine.execute(sqlalchemy.sql.text(cmd), tax_id=parent_id)
          keys = list(result.keys())
          rows = [dict(list(zip(keys, row))) for row in result.fetchall()]
          for r in rows:
              if r['rank'] == rank and 'sp.' not in r['tax_name']:
                  species.append(r)
          others = [r for r in rows if r['rank'] not in (rank, 'no_rank')]
          if others:
              _, s = get_children(engine, [r['tax_id'] for r in others])
              species.extend(s)
  
      return keys, species