public function ElementsByNamespaces( $namespaces )
	{
		if ( is_string( $namespaces ) )
			$namespaces = array_map( 'trim', explode( ",", $namespaces ) );

		if ( ! is_array( $namespaces ) )
			throw new Exception( 'InstanceElementsFilter::ElementsByName $namespaces must be a string or array' );

		$namespaces = array_flip( array_map( 'strtolower', $namespaces ) );

		$instance_namespaces = $this->instance->getInstanceNamespaces();

		// In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions
		$elements = &$this->elements;

		$filtered = array_reduce( array_keys( $this->elements ), function( $carry, $elementName ) use( &$elements, $instance_namespaces, $namespaces ) {

			$namespaceElements = array_filter( $elements[ $elementName ], function( $entry ) use( &$elements, $instance_namespaces, $namespaces ) {
				$namespace = isset( $instance_namespaces[ $entry['namespace'] ] ) ? $instance_namespaces[ $entry['namespace'] ] : $entry['namespace'];
				return isset( $namespaces[ strtolower( $namespace ) ] );
			} );

			if ( ! $namespaceElements ) return $carry;

			$carry[ $elementName ] = $namespaceElements;

			return $carry;

		}, array() );

		return new InstanceElementsFilter( $this->instance, $filtered );
	}