code: def get_external_base_image(self, image, stack=None):
          
          if stack is None:
              stack = list()
  
          mydef = self.ymldefs[image]
  
          if image in stack:
              stack.append(image)
              raise errors.CircularDependencyError('Circular dependency found:\n' + '->'.join(stack))
          stack.append(image)
  
          # Deal with FROM and FROM_DOCKERFILE fields
          if 'FROM' in mydef and 'FROM_DOCKERFILE' in mydef:
              raise errors.MultipleBaseError(
                      'ERROR: Image "%s" has both a "FROM" and a "FROM_DOCKERFILE" field.' % image +
                      '       It should have at most ONE of these fields.')
          if 'FROM' in mydef:
              externalbase = mydef['FROM']
          elif 'FROM_DOCKERFILE' in mydef:
              path = mydef['FROM_DOCKERFILE']
              if path not in self._external_dockerfiles:
                  self._external_dockerfiles[path] = ExternalDockerfile(path)
              externalbase = self._external_dockerfiles[path]
          else:
              externalbase = None
  
          requires = mydef.get('requires', [])
          if not isinstance(requires, list):
              raise errors.InvalidRequiresList('Requirements for image "%s" are not a list' % image)
  
          for base in requires:
              try:
                  otherexternal = self.get_external_base_image(base, stack)
              except ValueError:
                  continue
  
              if externalbase is None:
                  externalbase = otherexternal
              elif otherexternal is None:
                  continue
              elif externalbase != otherexternal:
                  raise errors.ConflictingBaseError(
                          'Multiple external dependencies: definition "%s" depends on:\n' % image +
                          '  %s (FROM: %s), and\n' % (image, externalbase) +
                          '  %s (FROM: %s).' % (base, otherexternal))
  
          assert stack.pop() == image
          return externalbase
docs: Makes sure that this image has exactly one unique external base image