@Nonnull
	public static <T, N extends Node> CompletableFuture<T> whenAddedToSceneMap(@Nonnull N node, @Nonnull Function<N, T> function) {
		// If added to the UI, immediately look up value.
		if (node.getScene() != null) return CompletableFuture.completedFuture(function.apply(node));

		// When there is no scene it is not added to the UI yet.
		// We want to wait for it to be added before calling the function.
		CompletableFuture<T> future = new CompletableFuture<>();
		node.sceneProperty().addListener(new ChangeListener<>() {
			@Override
			public void changed(ObservableValue<? extends Scene> observable, Scene prior, Scene current) {
				node.sceneProperty().removeListener(this);
				future.complete(function.apply(node));
			}
		});
		return future;
	}
@param node
		Node to initiate query with.
@param function
		Function taking in the node and yielding some value. To be run when the node has a {@link Scene} associated with it.
@param <T>
		Function return type.
@param <N>
		Node type.

@return Future of function lookup.
recaf-ui/src/main/java/software/coley/recaf/util/SceneUtils.java