def filter_nodes(n: Node, query: str) -> CompatNodeIterator:
    """
    Utility function. Same as filter() but will only filter for nodes (i. e.
    it will exclude scalars and positions).
    """
    return CompatNodeIterator(filter(n, query)._nodeit, only_nodes=True)