public List<PackagingElementNode<?>> getNodesByPath(List<? extends PackagingElement<?>> pathToPlace) {
    List<PackagingElementNode<?>> result = new ArrayList<>();
    PackagingElementNode<?> current = this;
    int i = 0;
    result.add(current);
    while (current != null && i < pathToPlace.size()) {
      final SimpleNode[] children = current.getCached();
      if (children == null) {
        break;
      }

      PackagingElementNode<?> next = null;
      final PackagingElement<?> element = pathToPlace.get(i);

      search:
      for (SimpleNode child : children) {
        if (child instanceof PackagingElementNode<?> childNode) {
          for (PackagingElement<?> childElement : childNode.getPackagingElements()) {
            if (childElement.isEqualTo(element)) {
              next = childNode;
              break search;
            }
          }
          for (PackagingNodeSource nodeSource : childNode.getNodeSources()) {
            if (nodeSource.getSourceElement().isEqualTo(element)) {
              next = current;
              break search;
            }
          }
        }
      }
      current = next;
      if (current != null) {
        result.add(current);
      }
      i++;
    }
    return result;
  }
public List<PackagingElementNode<?>> getNodesByPath(List<? extends PackagingElement<?>> pathToPlace)