def _RecurseKey(self, recur_item, root='', depth=15):
    """Flattens nested dictionaries and lists by yielding their values.

    The hierarchy of a bencode file is a series of nested dictionaries and
    lists. This is a helper function helps plugins navigate the structure
    without having to reimplement their own recursive methods.

    This method implements an overridable depth limit to prevent processing
    extremely deeply nested dictionaries. If the limit is reached a debug
    message is logged indicating which key processing stopped on.

    Args:
      recur_item (object): object to be checked for additional nested items.
      root (str): the pathname of the current working key.
      depth (int): a counter to ensure we stop at the maximum recursion depth.

    Yields:
      tuple: containing:
          str: root
          str: key
          str: value
    """
    if depth < 1:
      logger.debug('Recursion limit hit for key: {0:s}'.format(root))
      return

    if isinstance(recur_item, (list, tuple)):
      for recur in recur_item:
        for key in self._RecurseKey(recur, root, depth):
          yield key
      return

    if not hasattr(recur_item, 'iteritems'):
      return

    for key, value in iter(recur_item.items()):
      yield root, key, value
      if isinstance(value, dict):
        value = [value]
      if isinstance(value, list):
        for item in value:
          if isinstance(item, dict):
            for keyval in self._RecurseKey(
                item, root=root + '/' + key, depth=depth - 1):
              yield keyval
Flattens nested dictionaries and lists by yielding their values.

    The hierarchy of a bencode file is a series of nested dictionaries and
    lists. This is a helper function helps plugins navigate the structure
    without having to reimplement their own recursive methods.

    This method implements an overridable depth limit to prevent processing
    extremely deeply nested dictionaries. If the limit is reached a debug
    message is logged indicating which key processing stopped on.

    Args:
      recur_item (object): object to be checked for additional nested items.
      root (str): the pathname of the current working key.
      depth (int): a counter to ensure we stop at the maximum recursion depth.

    Yields:
      tuple: containing:
          str: root
          str: key
          str: value