// 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;
  }

  /**
   * @throws UnreachableSourceException If render at this level is shadowed by a descendant with the
   * same path, then there is no node at this level; the path will always be inherited lower in the
   * hierarchy.
   */
  private RenderedSource sourceFor(RenderedNode render, int level) {
    RenderedSourceCacheKey key = new RenderedSourceCacheKey(render, level);

    if (cachedRenderedSources.containsKey(key)) {
      Object sourceOrException = cachedRenderedSources.get(key);
      if (sourceOrException instanceof RenderedSource) {
        return (RenderedSource) sourceOrException;
      }
      //noinspection ConstantConditions
      throw (UnreachableSourceException) sourceOrException;
    }

    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 {
// 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;

  }

  /**
   * @throws UnreachableSourceException If render at this level is shadowed by a descendant with the
   * same path, then there is no node at this level; the path will always be inherited lower in the
   * hierarchy.
   */
  private RenderedSource sourceFor(RenderedNode render, int level) {
    RenderedSourceCacheKey key = new RenderedSourceCacheKey(render, level);

    if (cachedRenderedSources.containsKey(key)) {
      Object sourceOrException = cachedRenderedSources.get(key);
      if (sourceOrException instanceof RenderedSource) {
        return (RenderedSource) sourceOrException;
      }
      //noinspection ConstantConditions
      throw (UnreachableSourceException) sourceOrException;
    }

    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;