Implement new amd filter that works with trees.