class MemoryObjectTreeNode implements MutableTreeNode {

  @NotNull
  public List<MemoryObjectTreeNode<T>> getPathToRoot() {
    List<MemoryObjectTreeNode<T>> path = new ArrayList<>();
    MemoryObjectTreeNode<T> currentNode = this;
    MemoryObjectTreeNode<T> cycleDetector = this;
    while (currentNode != null) {
      for (int i = 0; i < 2 && cycleDetector != null; i++) {
        assert cycleDetector.myParent != currentNode;
        cycleDetector = cycleDetector.myParent;
      }

      path.add(currentNode);
      currentNode = currentNode.myParent;
    }
    Collections.reverse(path);
    return path;
  }

  public  MemoryObjectTreeNode(@NotNull T adapter);

}