code: def to_predicate(filter: Filter) -> Predicate:
      if isinstance(filter, str):
          return AtPath(filter)
      elif isinstance(filter, type):
          return OfType(filter)
      elif isinstance(filter, bool):
          return Everything() if filter else Nothing()
      elif filter is Ellipsis:
          return Everything()
      elif filter is None:
          return Nothing()
      elif callable(filter):
          return filter
      elif isinstance(filter, (list, tuple)):
          return Any(*filter)
      else:
          raise TypeError(f"Invalid collection filter: {filter:!r}. ")
  
imports: import builtins
  import dataclasses
  import typing
label_desc: Use image node_id 1 for calling a global function with example usage: to_predicate(filter) and returns: AtPath, OfType, unknown, Everything, Nothing, filter, Any