code: def apply(func, value, apply_to_keys=False):
      """
      Applies func to every possible member of value
      :param value: could be either a primitive object or a complex one (list, dicts)
      :param func: func to be applied
      :return:
      """
  
      def _apply(func, value, value_path):
          if value_path is None:
              value_path = []
  
          if isinstance(value, list) or isinstance(value, tuple):
              res = []
              for ind, item in enumerate(value):
                  path = copy.copy(value_path)
                  path.append(ind)
                  res.append(_apply(func, item, path))
          elif isinstance(value, dict):
              if is_external(value):
                  # this is a special serialized object pointing to some external place
                  res = func(value, value_path)
              else:
                  res = {}
                  for key, val in sorted(
                      value.items(), key=lambda dict_item: dict_item[0]
                  ):
                      path = copy.copy(value_path)
                      path.append(key)
                      res[
                          _apply(func, key, path)
                          if apply_to_keys
                          else key
                      ] = _apply(func, val, path)
          else:
              res = func(value, value_path)
          return res
  
      return _apply(func, value, None)
  
imports: from __future__ import absolute_import
  import re
  import sys
  import copy
  import logging
  from .None import tools
  from datetime import date, datetime
  import enum
  import six
label_desc: Use image node_id 1 for calling a global function with example usage: apply(func, value, apply_to_keys) and returns: _apply, res