class_docstr: Provide a few methods necessary to support nipype interface api
  
  The inputs attribute of interfaces call certain methods that are not
  available in traits.HasTraits. These are provided here.
  
  new metadata:
  
  * usedefault : set this to True if the default value of the trait should be
    used. Unless this is set, the attributes are set to traits.Undefined
  
  new attribute:
  
  * get_hashval : returns a tuple containing the state of the trait as a dict
    and hashvalue corresponding to dict.
  
  XXX Reconsider this in the long run, but it seems like the best
  solution to move forward on the refactoring.
class_docstr_tok: ["Provide","a","few","methods","necessary","to","support","nipype","interface","api","The","inputs","attribute","of","interfaces","call","certain","methods","that","are","not","available","in","traits.HasTraits",".","These","are","provided","here",".","new","metadata",":","*","usedefault",":","set","this","to","True","if","the","default","value","of","the","trait","should","be","used",".","Unless","this","is","set",",","the","attributes","are","set","to","traits.Undefined","new","attribute",":","*","get_hashval",":","returns","a","tuple","containing","the","state","of","the","trait","as","a","dict","and","hashvalue","corresponding","to","dict",".","XXX","Reconsider","this","in","the","long","run",",","but","it","seems","like","the","best","solution","to","move","forward","on","the","refactoring","."]
code: def _get_sorteddict(
      self,
      objekt,
      dictwithhash=False,
      hash_method=None,
      hash_files=True,
  ):
      if isinstance(objekt, dict):
          out = []
          for key, val in sorted(objekt.items()):
              if isdefined(val):
                  out.append(
                      (
                          key,
                          self._get_sorteddict(
                              val,
                              dictwithhash,
                              hash_method=hash_method,
                              hash_files=hash_files,
                          ),
                      )
                  )
      elif isinstance(objekt, (list, tuple)):
          out = []
          for val in objekt:
              if isdefined(val):
                  out.append(
                      self._get_sorteddict(
                          val,
                          dictwithhash,
                          hash_method=hash_method,
                          hash_files=hash_files,
                      )
                  )
          if isinstance(objekt, tuple):
              out = tuple(out)
      else:
          out = None
          if isdefined(objekt):
              if (
                  hash_files
                  and isinstance(objekt, (str, bytes))
                  and os.path.isfile(objekt)
              ):
                  if hash_method is None:
                      hash_method = config.get(
                          "execution", "hash_method"
                      )
  
                  if hash_method.lower() == "timestamp":
                      hash = hash_timestamp(objekt)
                  elif hash_method.lower() == "content":
                      hash = hash_infile(objekt)
                  else:
                      raise Exception(
                          "Unknown hash method: %s" % hash_method
                      )
                  if dictwithhash:
                      out = (objekt, hash)
                  else:
                      out = hash
              elif isinstance(objekt, float):
                  out = _float_fmt(objekt)
              else:
                  out = objekt
      return out
  
imports: import os
  from inspect import isclass
  from copy import deepcopy
  from warnings import warn
  from packaging.version import Version
  from traits.trait_errors import TraitError
  from traits.trait_handlers import TraitDictObject, TraitListObject
  from ...utils.filemanip import md5, hash_infile, hash_timestamp
  from .traits_extension import traits, File, Str, Undefined, isdefined, has_metadata, OutputMultiObject
  from ...None import config, __version__
label_desc: Use image node_id 12 for calling the BaseTraitedSpec obj's underlying member method code with example usage: obj._get_sorteddict(objekt, dictwithhash, hash_method, hash_files) and returns: out