Refactor hasElement and hasPhase predicates