[IMP] Make compatible with php 5.4

Loop popping a list is very inefficient.
If you're expecting a long list try:
```python
   def remove_trailing(l, remove_value=None):
        i = len(l)
        while i>0 and l[i-1] == remove_value:
            i -= 1
        return l[:i]
```

The thing is, when you pop or append from a list, internally the list will eventually resize, which means copying the contents to another place in memory. Because of this, doing it in a loop is a problem because it could resize N times giving it a performance of O(n2) or O(nlogn)