class_docstr: Parse HOCON files: https://github.com/typesafehub/config/blob/master/HOCON.md
class_docstr_tok: ["Parse","HOCON","files",":","https",":","\/\/github.com\/typesafehub\/config\/blob\/master\/HOCON.md"]
code: def _fixup_self_references(cls, config, accept_unresolved=False):
      if isinstance(config, ConfigTree) and config.root:
          for key in config:  # Traverse history of element
              history = config.history[key]
              previous_item = history[0]
              for current_item in history[1:]:
                  for substitution in cls._find_substitutions(
                      current_item
                  ):
                      prop_path = ConfigTree.parse_key(
                          substitution.variable
                      )
                      if (
                          len(prop_path) > 1
                          and config.get(substitution.variable, None)
                          is not None
                      ):
                          continue  # If value is present in latest version, don't do anything
                      if prop_path[0] == key:
                          if (
                              isinstance(previous_item, ConfigValues)
                              and not accept_unresolved
                          ):
                              # We hit a dead end, we cannot evaluate
                              raise ConfigSubstitutionException(
                                  "Property {variable} cannot be substituted. Check for cycles.".format(
                                      variable=substitution.variable
                                  )
                              )
                          else:
                              value = (
                                  previous_item
                                  if len(prop_path) == 1
                                  else previous_item.get(
                                      ".".join(prop_path[1:])
                                  )
                              )
                              _, _, current_item = cls._do_substitute(
                                  substitution, value
                              )
                  previous_item = current_item
  
              if len(history) == 1:
                  for substitution in cls._find_substitutions(
                      previous_item
                  ):
                      prop_path = ConfigTree.parse_key(
                          substitution.variable
                      )
                      if (
                          len(prop_path) > 1
                          and config.get(substitution.variable, None)
                          is not None
                      ):
                          continue  # If value is present in latest version, don't do anything
                      if prop_path[0] == key and substitution.optional:
                          cls._do_substitute(substitution, None)
                      if prop_path[0] == key:
                          value = os.environ.get(key)
                          if value is not None:
                              cls._do_substitute(substitution, value)
                              continue
                          if (
                              substitution.optional
                          ):  # special case, when self optional referencing without existing
                              cls._do_substitute(substitution, None)
  
imports: import itertools
  import re
  import os
  import socket
  import contextlib
  import codecs
  from datetime import timedelta
  from pyparsing import Forward, Keyword, QuotedString, Word, Literal, Suppress, Regex, Optional, SkipTo, ZeroOrMore, Group, lineno, col, TokenConverter, replaceWith, alphanums, alphas8bit, ParseSyntaxException, StringEnd
  from pyparsing import ParserElement
  from .config_tree import ConfigTree, ConfigSubstitution, ConfigList, ConfigValues, ConfigUnquotedString, ConfigInclude, NoneValue, ConfigQuotedString
  from .exceptions import ConfigSubstitutionException, ConfigMissingException, ConfigException
  import logging
  import copy
label_desc: Use image node_id 4 for calling the ConfigParser obj's underlying member method code with example usage: obj._fixup_self_references(cls, config, accept_unresolved) without return types