protected function analyzeContexts( $instance )
	{
		$contexts = $instance->getContexts()->getContexts();
		$elements = $instance->getElements()->getElements();

		foreach ( $elements as $elementKey => $element )
		{
			foreach ( $element as $entryKey => $entry )
			{
				if ( ! isset( $entry['contextRef'] ) )
					continue;

				if ( isset( $instance->usedContexts[ $entry['contextRef'] ] ) ) continue;

				$instance->usedContexts[ $entry['contextRef'] ] = $contexts[ $entry['contextRef'] ];
				$instance->usedContexts[ $entry['contextRef'] ]['year'] = substr( $contexts[ $entry['contextRef'] ]['period']['endDate'], 0, 4 );
			}
		}

		if ( ! is_array( $this->years ) ) $this->years = array();

		foreach ( $instance->usedContexts as $key => $context )
		{
			$year = $context['year'];
			$entity = $context['entity']['identifier']['value'];

			if ( ! isset( $this->years[ $year ] ) ) $this->years[ $year ] = array();
			if ( ! isset( $this->years[ $year ][ $entity ] ) ) $this->years[ $year ][ $entity ] = array();
			$this->years[ $year ][ $entity ][ $key ] = $context;
		}

		// ksort( $this->years );
		// print_r( array_keys( $this->years ) );

		if ( ! is_array( $this->entities ) ) $this->entities = array();

		foreach ( $instance->usedContexts as $key => $context )
		{
			$entity = $context['entity']['identifier']['value'];
			$this->entityInstanceMap[ $entity ] = $instance->getDocumentName();

			if ( ! isset( $this->entities[ $entity ] ) ) $this->entities[ $entity ] = array();
			$this->entities[ $entity ][ $key ] = $context;
		}
	}