Ecosystems and Immune Systems: Hierarchical Response Provides Resilience against Invasions