protected Node fromRepository(
      CmrRepository repository, ArtifactContext context, boolean addLeaf) {
    log.debug(" Trying repository " + repository.getDisplayString());
    Node node = repository.findParent(context);
    if (node != null) {
      if (addLeaf) {
        Node parent = node;
        context.toNode(parent);
        NodeUtils.keepRepository(parent, repository);
        try {
          String[] names = repository.getArtifactNames(context);
          for (String name : names) {
            node = parent.getChild(name);
            if (node != null) {
              break;
            }
          }
        } finally {
          ArtifactContext.removeNode(parent);
        }
      }

      if (node != null) {
        NodeUtils.keepRepository(node, repository);
        log.debug("  -> Found at " + NodeUtils.getFullPath(node));
      }
    }
    return node;
  }
  protected Node getLeafNode(ArtifactContext context) {
    final Node node = getFromAllRoots(context, true);
    if (node == null) {
      if (context.isThrowErrorIfMissing())
        throw new IllegalArgumentException("No such artifact: " + context);
      return null;
    }

    // save the context info
    context.toNode(node);

    return node;
  }