Remove branches from loop by removing invalid data from the container being looped over