// Path: lib/src/io/github/alechenninger/monarch/DynamicNode.java
// final class RenderedNode {
//   private final DynamicNode node;
//   private final String path;
//   private final Set<Assignment> usedAssignments;
//   private final int hash;
// 
//   public RenderedNode(String path, Set<Assignment> usedAssignments, DynamicNode node) {
//     this.path = Objects.requireNonNull(path, "path");
//     this.usedAssignments = Objects.requireNonNull(usedAssignments, "usedAssignments");
//     this.node = Objects.requireNonNull(node, "node");
// 
//     hash = Objects.hash(node, path, usedAssignments);
//   }
// 
//   public String path() {
//     return path;
//   }
// 
//   public Set<Assignment> usedAssignments() {
//     return usedAssignments;
//   }
// 
//   public DynamicNode node() {
//     return node;
//   }
// 
//   @Override
//   public String toString() {
//     return "RenderedNode{" +
//         "node=" + node +
//         ", path='" + path + '\'' +
//         ", usedAssignments=" + usedAssignments +
//         '}';
//   }
// 
//   @Override
//   public boolean equals(Object o) {
//     if (this == o) return true;
//     if (o == null || getClass() != o.getClass()) return false;
//     RenderedNode that = (RenderedNode) o;
//     return Objects.equals(node, that.node) &&
//         Objects.equals(path, that.path) &&
//         Objects.equals(usedAssignments, that.usedAssignments);
//   }
// 
//   @Override
//   public int hashCode() {
//     return hash;
//   }
// }


import io.github.alechenninger.monarch.DynamicNode.RenderedNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
    try {
      RenderedSource source = new RenderedSource(render, level);
      cachedRenderedSources.put(key, source);
      return source;
    } catch (UnreachableSourceException e) {
      cachedRenderedSources.put(key, e);
      throw e;
    }
  }

  private static class RenderedSourceCacheKey {
    private final RenderedNode render;
    private final int level;
    private final int hash;

    private RenderedSourceCacheKey(RenderedNode render, int level) {
      this.render = render;
      this.level = level;
      hash = Objects.hash(render, level);
    }

    @Override
    public boolean equals(Object o) {
      if (this == o) return true;
      if (o == null || getClass() != o.getClass()) return false;
      RenderedSourceCacheKey renderedSourceCacheKey = (RenderedSourceCacheKey) o;
      return level == renderedSourceCacheKey.level &&
          Objects.equals(render, renderedSourceCacheKey.render);
    }

// Path: lib/src/io/github/alechenninger/monarch/DynamicNode.java
// final class RenderedNode {
//   private final DynamicNode node;
//   private final String path;
//   private final Set<Assignment> usedAssignments;
//   private final int hash;
// 
//   public RenderedNode(String path, Set<Assignment> usedAssignments, DynamicNode node) {
//     this.path = Objects.requireNonNull(path, "path");
//     this.usedAssignments = Objects.requireNonNull(usedAssignments, "usedAssignments");
//     this.node = Objects.requireNonNull(node, "node");
// 
//     hash = Objects.hash(node, path, usedAssignments);
//   }
// 
//   public String path() {
//     return path;
//   }
// 
//   public Set<Assignment> usedAssignments() {
//     return usedAssignments;
//   }
// 
//   public DynamicNode node() {
//     return node;
//   }
// 
//   @Override
//   public String toString() {
//     return "RenderedNode{" +
//         "node=" + node +
//         ", path='" + path + '\'' +
//         ", usedAssignments=" + usedAssignments +
//         '}';
//   }
// 
//   @Override
//   public boolean equals(Object o) {
//     if (this == o) return true;
//     if (o == null || getClass() != o.getClass()) return false;
//     RenderedNode that = (RenderedNode) o;
//     return Objects.equals(node, that.node) &&
//         Objects.equals(path, that.path) &&
//         Objects.equals(usedAssignments, that.usedAssignments);
//   }
// 
//   @Override
//   public int hashCode() {
//     return hash;
//   }
// }


// Path: lib/src/io/github/alechenninger/monarch/DynamicHierarchy.java
import io.github.alechenninger.monarch.DynamicNode.RenderedNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

    try {
      RenderedSource source = new RenderedSource(render, level);
      cachedRenderedSources.put(key, source);
      return source;
    } catch (UnreachableSourceException e) {
      cachedRenderedSources.put(key, e);
      throw e;
    }
  }

  private static class RenderedSourceCacheKey {
    private final RenderedNode render;
    private final int level;
    private final int hash;

    private RenderedSourceCacheKey(RenderedNode render, int level) {
      this.render = render;
      this.level = level;
      hash = Objects.hash(render, level);
    }

    @Override
    public boolean equals(Object o) {
      if (this == o) return true;
      if (o == null || getClass() != o.getClass()) return false;
      RenderedSourceCacheKey renderedSourceCacheKey = (RenderedSourceCacheKey) o;
      return level == renderedSourceCacheKey.level &&
          Objects.equals(render, renderedSourceCacheKey.render);
    }

    @Override