public function getMatchingComponent($component, $requesting_component) {
    if (is_null($requesting_component)) {
      return;
    }

    if (!$component->getMergeTag()) {
      return NULL;
    }

    // We've not added $component yet (and might not), so we don't know have
    // any data about it. So we need to use the requesting component to get the
    // closest requesting root.
    $requesting_component_id = $this->getComponentKey($requesting_component);
    if (isset($this->roots[$requesting_component_id])) {
      // If the requesting component is a root, it's obviously the closest
      // requesting root. But getClosestRequestingRootComponent() would not
      // give us this, as root's closest requester is not itself.
      $closest_requesting_root_id = $requesting_component_id;
    }
    else {
      $closest_requesting_root_id = $this->getComponentKey($this->getClosestRequestingRootComponent($requesting_component));
    }

    if (isset($this->mergeTags[$closest_requesting_root_id][$component->getType()][$component->getMergeTag()])) {
      $matching_component_id = $this->mergeTags[$closest_requesting_root_id][$component->getType()][$component->getMergeTag()];
      return $this->components[$matching_component_id];
    }
  }