code: def metadata(self, key=None, database=None, table=None, fallback=True):
          
          assert not (database is None and table is not None), \
              "Cannot call metadata() with table= specified but not database="
          databases = self._metadata.get("databases") or {}
          search_list = []
          if database is not None:
              search_list.append(databases.get(database) or {})
          if table is not None:
              table_metadata = (
                  (databases.get(database) or {}).get("tables") or {}
              ).get(table) or {}
              search_list.insert(0, table_metadata)
          search_list.append(self._metadata)
          if not fallback:
              # No fallback allowed, so just use the first one in the list
              search_list = search_list[:1]
          if key is not None:
              for item in search_list:
                  if key in item:
                      return item[key]
              return None
          else:
              # Return the merged list
              m = {}
              for item in search_list:
                  m.update(item)
              return m
docs: Looks up metadata, cascading backwards from specified level.
          Returns None if metadata value is not found.