private static @Nullable MyNode extractNode(@Nullable Object object) {
    if (object instanceof TreePath path) {
      object = path.getLastPathComponent();
    }
    if (object instanceof DefaultMutableTreeNode node) {
      object = node.getUserObject();
    }
    if (object instanceof FilteringTreeStructure.FilteringNode node) {
      object = node.getDelegate();
    }
    return object instanceof MyNode
           ? (MyNode)object
           : null;
  }
private static @Nullable MyNode extractNode(@Nullable Object object)