If the proto is empty, you are adding it to the list of properties here and then filtering it out at L168. Why can't you move that logic here and don't add the proto property when it's empty?

Why is it necessary to filter out the empty prototype object at all?